-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
PEP 749: Add a FAKE_GLOBALS_VALUE format #3991
Conversation
And some other changes from feedback by Larry.
Co-authored-by: Carl Meyer <[email protected]>
peps/pep-0749.rst
Outdated
@@ -27,7 +27,9 @@ specification: | |||
* We specify the behavior of wrapper objects that provide annotations, such as :py:func:`classmethod` | |||
and code that uses :py:func:`functools.wraps`. | |||
* There will not be a code flag for marking ``__annotate__`` functions | |||
that can be run in a "fake globals" environment. | |||
that can be run in a "fake globals" environment. Instead, we add a fourth format, | |||
``FAKE_GLOBALS_VALUE``, to allow third-party implementors of annotate functions to |
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.
It took me a bit to work out that this name was a combination of describing the output format and a difference in the supported inputs.
How would you feel about a more explicit separation of the two aspects, calling this format VALUE_WITH_FAKE_GLOBALS
?
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 like that, I'll ask Larry tomorrow to see if he agrees.
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.
After reviewing how the fake globals format is used, FORWARDREF_VIA_GLOBALS
is likely clearer, since this format injects fake globals to produce a FORWARDREF result that can be postprocessed to give a SOURCE result.
It doesn't emit the VALUE format, so having that in the name would be misleading.
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 feel it makes more sense to think of the format as "VALUE with an asterisk", since that's how __annotate__
functions should handle it internally.
this format injects fake globals to produce a FORWARDREF result that can be postprocessed to give a SOURCE result
That's not really how the implementation works. There isn't a forwardref involved in producing {"x": "int"}
out of the annotations for def f(x: int): pass
in SOURCE format.
This is a first round of changes as a result of feedback by @larryhastings; I may make some more changes, but need to think about them more first.
📚 Documentation preview 📚: https://pep-previews--3991.org.readthedocs.build/