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

None is not a valid value for ast.ImportFrom.level #92986

Open
hauntsaninja opened this issue May 19, 2022 · 0 comments
Open

None is not a valid value for ast.ImportFrom.level #92986

hauntsaninja opened this issue May 19, 2022 · 0 comments
Labels
stdlib type-bug

Comments

@hauntsaninja
Copy link
Contributor

@hauntsaninja hauntsaninja commented May 19, 2022

For example:

import ast
tree = ast.parse("from x import y")
tree.body[0].level = None
ast.unparse(tree)  # raises

This is very similar to https://bugs.python.org/issue46289 and #30467 cc @isidentical

Note the compiler does seem to allow it, but it's always an int in practice and documented as such

Discovered in typeshed.

@hauntsaninja hauntsaninja added the type-bug label May 19, 2022
hauntsaninja added a commit to hauntsaninja/cpython that referenced this issue May 19, 2022
hauntsaninja added a commit to hauntsaninja/cpython that referenced this issue May 19, 2022
This doesn't happen naturally, but is allowed by the ASDL and compiler.
We don't want to change ASDL for backward compatibility reasons
(python#57645, python#92987)
@AA-Turner AA-Turner added the stdlib label May 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib type-bug
Projects
None yet
Development

No branches or pull requests

2 participants