-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
ast.dump() elision of empty values should use field types #134718
Copy link
Copy link
Closed
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Bug report
Bug description:
In 3.13 we changed
ast.dump()to not show empty values (Noneor the empty list) by default. However, this is based purely on the value of individual attributes:Instead, this logic should look at the node's
_field_typesand use the same logic we use to determine whether to allow omitting the argument in calls to the constructor: elide None if the type is a union including None, elide[]if the type is a list, and elideLoad()if the type is an expr_context.CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs