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

Report error when variable is used uninitialized in a particular scope #7116

Closed
mthuurne opened this issue Jul 1, 2019 · 1 comment
Closed

Comments

@mthuurne
Copy link
Contributor

mthuurne commented Jul 1, 2019

  • Are you reporting a bug, or opening a feature request?
    Feature request.

The following code does not trigger any warnings in mypy 0.711:

def f(b: bool) -> int:
    if b:
        x = 123
        return x
    else:
        return x

I'm not sure 'uninitialized' qualifies as a type, but mypy does track execution paths to narrow types of variables within certain scopes, so it may not be too hard to detect errors like in the example above.

@msullivan
Copy link
Collaborator

Yeah, this would be useful. Duplicate of #4019, I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants