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
..
2024-02-12 09:04:36 +00:00
2023-11-27 18:58:43 +01:00
2023-12-20 14:27:25 +00:00
2024-01-16 09:32:01 +00:00
2024-01-16 09:32:01 +00:00
2024-02-10 12:21:35 +02:00
2023-09-30 22:21:20 +00:00
2024-02-20 09:57:48 -05:00
2024-02-23 17:31:57 +00:00
2024-02-20 09:57:48 -05:00
2024-02-23 17:31:57 +00:00
2024-02-20 20:24:35 +00:00
2023-11-30 11:12:49 +01:00
2024-02-23 12:35:27 +01:00
2024-02-02 13:50:51 +00:00
2024-02-16 01:01:36 +00:00
2023-11-08 15:39:29 -07:00
2024-02-13 14:56:49 -07:00
2024-02-13 14:56:49 -07:00
2024-02-13 14:56:49 -07:00
2023-12-07 13:47:55 +00:00
2023-09-02 16:50:18 +02:00
2023-10-04 22:50:29 +00:00
2023-10-04 22:50:29 +00:00
2023-10-04 22:50:29 +00:00
2023-10-04 22:50:29 +00:00
2023-09-08 17:54:45 +01:00
2023-09-15 15:04:21 -07:00
2023-12-21 01:46:41 +00:00
2024-02-23 17:31:57 +00:00
2023-12-12 11:25:27 +01:00
2024-02-22 12:36:44 +00:00
2023-06-02 01:33:17 +02:00
2024-02-01 18:26:22 +02:00
2023-12-03 12:18:24 +01:00
2023-09-30 20:06:45 +00:00
2023-07-03 22:35:46 +00:00
2024-02-20 23:31:30 +00:00
2024-02-14 00:32:51 +00:00
2024-02-20 23:31:30 +00:00
2024-02-23 17:31:57 +00:00
2024-02-08 01:04:41 -08:00
2024-01-16 21:54:05 +01:00
2023-09-29 10:56:49 +02:00
2023-08-24 18:53:50 +02:00
2023-12-06 15:09:22 +01:00
2024-02-20 22:16:37 +00:00
2023-10-04 22:50:29 +00:00
2024-02-23 10:27:07 +01:00
2024-02-26 17:51:47 +00:00
2023-11-14 00:31:02 +00:00
2024-02-26 08:32:44 -08:00
2023-11-03 16:39:50 +00:00
2024-02-20 22:16:37 +00:00
2024-01-16 18:05:15 +02:00
2023-10-11 14:44:06 +03:00
2023-09-03 18:54:27 +02:00
2024-02-16 01:01:36 +00:00
2023-12-20 15:09:12 +00:00
2024-02-27 13:25:02 +00:00
2024-02-27 13:25:02 +00:00
2024-02-27 13:25:02 +00:00
2024-02-27 13:25:02 +00:00
2024-02-26 17:51:47 +00:00
2024-02-20 22:16:37 +00:00
2023-09-29 10:56:49 +02:00
2023-12-21 19:28:55 +00:00
2023-07-04 09:41:43 +00:00
2023-12-06 15:09:22 +01:00
2024-02-26 17:51:47 +00:00
2024-02-26 17:51:47 +00:00
2023-09-01 18:36:53 +02:00
2023-09-02 23:15:54 +02:00
2023-09-06 15:56:08 +02:00
2024-02-27 18:13:03 -08:00
2023-12-11 11:44:22 +00:00
2024-02-25 12:45:38 -08:00
2024-02-21 11:46:00 +01:00
2024-02-16 15:25:19 -05:00
2024-02-26 17:51:47 +00:00
2024-01-08 15:10:45 +00:00
2024-02-11 12:45:58 +02:00
2024-01-11 20:31:24 +02:00
2024-02-17 12:06:31 +00:00
2024-02-26 17:51:47 +00:00
2024-02-21 11:46:00 +01:00
2023-11-04 13:59:24 +00:00
2024-02-21 11:46:00 +01:00
2024-02-21 11:46:00 +01:00
2024-02-20 09:39:55 +00:00
2024-01-16 09:32:01 +00:00
2023-09-06 15:56:08 +02:00
2023-11-01 22:55:10 +00:00