-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Possibly spurious SyntaxError: annotated name can't be global #79120
Comments
The following code when run as a script file gives syntax error:
PEP-526 does not seem to forbid this. The error message "annotated name [...] can't be global" is usually seen when using the Is this a bug in CPython? Or should the PEP-526 document say something about forward references? Interestingly, if the above program is run in interactive mode, there is no syntax error. In interactive mode:
Further, forward references work fine with
I don't see why a forward reference in |
The error message was added with 6cff874 and bpo-27999. The docs were also changed as below with the commit : https://docs.python.org/3.8/reference/simple_stmts.html#the-global-statement
Thanks |
Hm, I think this should be allowed. The formulation in the docs is not very clear, but the wording in the PEP clarifies the intention. Indeed, only annotations at the same scope with global declarations should be prohibited. So I think this is a bug. |
I agree with Ivan. |
This looks similar to say x = 1
global x It is an error in a file, but is not an error in interactive mode. |
Another point I'd like to make is that there is no error in either file or interactive if the annotated assignment appears before the
The syntax error specifically occurs when the annotated assignment occurs after a Neither the docs nor the PEP say anything about such an ordering constraint. |
I think we can just go ahead and allow this. If there is a volunteer, please go ahead, otherwise I will try to find time for this myself. |
* Split compatibility map into few YAML configurations * Refactoring in thirdparties enrichment * Implementation of thirdparties management automation * Haproxy and Keepalived no longer depend in Kubernetes version * Add synchronization of packages * Add synchronization of kubernetes images. * Rename plugins * Add synchronization of plugins * Move from globals.yaml and auto synchronize supported kubernetes_versions * Make manifest enrichment independent on cluster and run test enrichment * Workaround python/cpython#79120 * Implement simple test of thirdparties sync * Stage all changed and added files * Print links to software requirements * Take package versions from previous Kubernetes version * Changes to support PR #416 * Add more integration tests * Refactoring for unit tests * Implement unit tests * Remove unnecessary option * Auto-update license header * Fix upgrade of pause and reconfigure containerd --------- Co-authored-by: ilia1243 <ilia1243@users.noreply.github.com>
* Adding support for OpenSSH ecdsa-sk & ed25519-sk public keys fixes #10604 * Revert changing the keygen * Add application string to sk key generation * Typing - fix load_application return value annotation * fix sk keys skipping loading in the tests * fix ruff E509 * Fix ruff … * comment wording Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com> * requested changes * no subclassing * fix SyntaxError: annotated name '_KEY_FORMATS' can't be global in python 3.7 c.f. python/cpython#79120 * typo * Update src/cryptography/hazmat/primitives/serialization/ssh.py Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com> * Update src/cryptography/hazmat/primitives/serialization/ssh.py Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com> --------- Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: