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

Using not yet defined variables is allowed #2788

Open
afrieder opened this issue Feb 1, 2017 · 2 comments
Open

Using not yet defined variables is allowed #2788

afrieder opened this issue Feb 1, 2017 · 2 comments
Labels
bug mypy got something wrong priority-2-low topic-runtime-semantics mypy doesn't model runtime semantics correctly topic-variable-scope

Comments

@afrieder
Copy link
Contributor

afrieder commented Feb 1, 2017

This might be the same issue as #937 but this raises no errors:

s += 1
s: int = 0

or

x: int
x += 1
@JukkaL
Copy link
Collaborator

JukkaL commented Feb 7, 2017

Mypy will catch the first case if it's within a function:

def f() -> None:
    s += 1   # Name 's' is not defined
    s: int = 0

This should be rejected at the top level of a file as well. The second case is arguably different and would require keeping track of when variables are defined or not. I remember having seen an issue about this but I can't find it right now.

@KotlinIsland
Copy link
Contributor

Duplicate of #686?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong priority-2-low topic-runtime-semantics mypy doesn't model runtime semantics correctly topic-variable-scope
Projects
None yet
Development

No branches or pull requests

4 participants