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

UnboundLocalError in nested function is not detected by mypy #13988

Closed
ltworf opened this issue Nov 2, 2022 · 1 comment
Closed

UnboundLocalError in nested function is not detected by mypy #13988

ltworf opened this issue Nov 2, 2022 · 1 comment
Labels
bug mypy got something wrong

Comments

@ltworf
Copy link

ltworf commented Nov 2, 2022

Bug Report

Mypy does not detect invalid usage within nested functions. This might be a duplicate of #8746 but I thought it's a different issue.

To Reproduce

def a() -> None:
    val = 0
    def b() -> None:
        val += 1
    b()
a()

Expected Behavior

I'd like mypy to mark val += 1 as an error, as the runtime does

Actual Behavior

Code is considered correct.

Your Environment

  • Mypy version used: 0.982
  • Mypy command-line flags: None
  • Python version used: 3.10.8
@ltworf ltworf added the bug mypy got something wrong label Nov 2, 2022
@hauntsaninja
Copy link
Collaborator

mypy mostly doesn't complain about UnboundLocalErrors, this is being actively worked on. Duplicate of #2400 , #686 , etc

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants