Repository navigation
Improve the constructors of AST nodes #105858
Copy link
Copy link
Closed
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-parsertype-featureA feature request or enhancementA feature request or enhancement
Description
Activity
- addedtype-featureA feature request or enhancementA feature request or enhancement
on Jun 16, 2023 CC: @isidentical
- added a commit that references this issue
on Jun 17, 2023 Yes please! This has been such a pain point for me.
One note: we should probably only default optional fields (
?) toNone, and require everything else.One note: we should probably only default optional fields (
?) toNone, and require everything else.Agree, I ended up doing that in my draft PR. Omitting a required field (e.g.
FunctionDef.name) will raise a DeprecationWarning, as will passing a bogus field.Reacted by Brandt Bucher, Oleg Iarygin and chirk- addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
on Nov 27, 2023 - added a commit that references this issue
on Feb 28, 2024 Merged!
Reacted by Alex WaygoodReopening as I broke all the buildbots
There might be a regression: #117266
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-parsertype-featureA feature request or enhancementA feature request or enhancement
Currently, the constructors for AST nodes accept arbitrary keyword arguments and don't enforce any value:
Problems with the current situation:
namebeing present__match_args__attributes of AST nodes #104799)Proposed solution for 3.13:
whatabove). In 3.15, this will raise an error.__text_signature__to the AST classes indicating the expected signature.Linked PRs