-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
PEP 810: Update decisions on with blocks and __dict__ reification #4656
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
base: main
Are you sure you want to change the base?
Conversation
This commit updates PEP 810 based on team discussion and feedback: 1. Allow lazy imports inside with blocks - Removed with blocks from syntax restrictions - Added rejected ideas section explaining why restriction was considered 2. __dict__ does not automatically reify lazy imports - Both globals() and __dict__ return raw dictionary without reification - Updated reification section, FAQ, and rejected ideas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with
block stuff LGTM, except for one note.
tools and linters are better suited to catch these patterns than hard language | ||
restrictions. | ||
|
||
Additionally, forbidding explicit ``lazy import`` in ``with`` blocks would |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is any more true than the try
/except
case, no? It's not really more complexity than the current PEP unless you also have the part where implicit lazy is forced eager in with
blocks.
does **not** automatically reify lazy imports -- you'll see the lazy proxy | ||
objects themselves, which you can then manually resolve if needed. | ||
|
||
What's the difference between ``globals()`` and ``mod.__dict__`` for lazy imports? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This entire question now doesn't make sense anymore. There isn't a difference between them, is there? Can we just remove this FAQ entry?
Co-authored-by: T. Wouters <[email protected]>
Co-authored-by: T. Wouters <[email protected]>
Co-authored-by: T. Wouters <[email protected]>
# Accessing __dict__ from external code DOES reify all lazy imports | ||
d = my_module.__dict__ | ||
the object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint fix
the object. | |
the object. |
This commit updates PEP 810 based on team discussion and feedback:
Allow lazy imports inside with blocks
dict does not automatically reify lazy imports
globals()
and__dict__
return raw dictionary without reification📚 Documentation preview 📚: https://pep-previews--4656.org.readthedocs.build/