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

Is an unused variable annotation able to be detected? #546

Closed
scottbelden opened this issue May 20, 2020 · 1 comment · Fixed by #668
Closed

Is an unused variable annotation able to be detected? #546

scottbelden opened this issue May 20, 2020 · 1 comment · Fixed by #668

Comments

@scottbelden
Copy link

Given this sample file:

def foo():
    a = 10
    b: str
    return 1


foo()

It correctly gives an error about the variable a: test.py:2:5 local variable 'a' is assigned to but never used

It would be nice if an error could be given about b as well since it is also never used. I'm not sure if this is a bug report or a feature request, but I just wasn't sure if this was possible.

@asottile
Copy link
Member

yep this is possible -- this would probably be a feature (and a separate code) since it's a little different than our name binding right now

it is possible to detect this case, and I believe the work done in #535 will make this very easy to implement!

there's even a TODO mentioning your expected behaviour: https://github.com/PyCQA/pyflakes/pull/535/files#diff-8dd6768783dc8a438172318bc691ac3eR294

if you'd like to help move it forward, I'd suggest trying out that branch and if you're up for it reviewing the code

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

Successfully merging a pull request may close this issue.

2 participants