Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default expr_context parameters in ast to Load() #118851

Closed
JelleZijlstra opened this issue May 9, 2024 · 0 comments
Closed

Default expr_context parameters in ast to Load() #118851

JelleZijlstra opened this issue May 9, 2024 · 0 comments
Assignees
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes type-feature A feature request or enhancement

Comments

@JelleZijlstra
Copy link
Member

JelleZijlstra commented May 9, 2024

Feature or enhancement

Proposal:

In #105858, we changed the AST node constructors to raise a DeprecationWarning when any required fields are omitted. Optional fields default to None and list fields default to an empty list. In real-world usage, it emerges that it's often also useful to omit the ctx argument to various classes (Attribute, Subscript, Starred, Name, List, Tuple); its value often does not matter, and it's convenient to have it default to ast.Load().

I'd like to backport this to 3.13 since it helps undo a noisy DeprecationWarning.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

python/typeshed#11880 (comment)

Linked PRs

@JelleZijlstra JelleZijlstra added type-feature A feature request or enhancement 3.13 bugs and security fixes 3.14 new features, bugs and security fixes labels May 9, 2024
@JelleZijlstra JelleZijlstra self-assigned this May 9, 2024
JelleZijlstra added a commit to JelleZijlstra/cpython that referenced this issue May 9, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 9, 2024
…ythonGH-118854)

(cherry picked from commit 68fbc00)

Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
JelleZijlstra added a commit that referenced this issue May 9, 2024
…GH-118854) (#118871)

(cherry picked from commit 68fbc00)

Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
SonicField pushed a commit to SonicField/cpython that referenced this issue May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants