mirror of
https://github.com/python/cpython.git
synced 2024-11-24 02:15:30 +08:00
ed4dfd8825
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> |
||
---|---|---|
.. | ||
lexer | ||
tokenizer | ||
action_helpers.c | ||
asdl_c.py | ||
asdl.py | ||
myreadline.c | ||
parser.c | ||
peg_api.c | ||
pegen_errors.c | ||
pegen.c | ||
pegen.h | ||
Python.asdl | ||
string_parser.c | ||
string_parser.h | ||
token.c |