0
0
mirror of https://github.com/python/cpython.git synced 2024-12-01 11:15:56 +01:00
cpython/Parser
Jelle Zijlstra ed4dfd8825
gh-105858: Improve AST node constructors (#105880)
Demonstration:

>>> ast.FunctionDef.__annotations__
{'name': <class 'str'>, 'args': <class 'ast.arguments'>, 'body': list[ast.stmt], 'decorator_list': list[ast.expr], 'returns': ast.expr | None, 'type_comment': str | None, 'type_params': list[ast.type_param]}
>>> ast.FunctionDef()
<stdin>:1: DeprecationWarning: FunctionDef.__init__ missing 1 required positional argument: 'name'. This will become an error in Python 3.15.
<stdin>:1: DeprecationWarning: FunctionDef.__init__ missing 1 required positional argument: 'args'. This will become an error in Python 3.15.
<ast.FunctionDef object at 0x101959460>
>>> node = ast.FunctionDef(name="foo", args=ast.arguments())
>>> node.decorator_list
[]
>>> ast.FunctionDef(whatever="you want", name="x", args=ast.arguments())
<stdin>:1: DeprecationWarning: FunctionDef.__init__ got an unexpected keyword argument 'whatever'. Support for arbitrary keyword arguments is deprecated and will be removed in Python 3.15.
<ast.FunctionDef object at 0x1019581f0>
2024-02-27 18:13:03 -08:00
..
lexer gh-114569: Use PyMem_* APIs for most non-PyObject uses (#114574) 2024-01-26 10:11:35 +00:00
tokenizer
action_helpers.c
asdl_c.py gh-105858: Improve AST node constructors (#105880) 2024-02-27 18:13:03 -08:00
asdl.py
myreadline.c
parser.c gh-115881: Ensure ast.parse() parses conditional context managers even with low feature_version passed (#115920) 2024-02-26 09:22:09 +00:00
peg_api.c
pegen_errors.c gh-115823: Calculate correctly error locations when dealing with implicit encodings (#115824) 2024-02-26 12:57:09 +00:00
pegen.c gh-113744: Add a new IncompleteInputError exception to improve incomplete input detection in the codeop module (#113745) 2024-01-30 16:21:30 +00:00
pegen.h gh-112943: Correctly compute end offsets for multiline tokens in the tokenize module (#112949) 2023-12-11 11:44:22 +00:00
Python.asdl
string_parser.c
string_parser.h
token.c