>> node.what 'is this' >>> node.name Traceback (m...">

Improve the constructors of AST nodes · Issue #105858 · python/cpython (original) (raw)

Currently, the constructors for AST nodes accept arbitrary keyword arguments and don't enforce any value:

node=ast.FunctionDef(what="is this") node.what 'is this' node.name Traceback (most recent call last): File "", line 1, in AttributeError: 'FunctionDef' object has no attribute 'name'

Problems with the current situation:

Proposed solution for 3.13:

Linked PRs