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

Spurious F841 in exception even when referenced by locals() #376

Closed
jaraco opened this issue Oct 26, 2018 · 2 comments
Closed

Spurious F841 in exception even when referenced by locals() #376

jaraco opened this issue Oct 26, 2018 · 2 comments

Comments

@jaraco
Copy link
Contributor

jaraco commented Oct 26, 2018

I recently upgraded to flake8 3.6 and pyflakes 2.0.0, and now I'm getting failures in code where locals() contains the only reference to a variable in the namespace.

draft $ cat > f841fail.py
try:
    raise ValueError()
except Exception as e:
    print(locals())
draft $ python f841fail.py
{'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <_frozen_importlib_external.SourceFileLoader object at 0x10138c710>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, '__file__': 'f841fail.py', '__cached__': None, 'e': ValueError()}
draft $ flake8 --version
3.6.0 (mccabe: 0.6.1, pycodestyle: 2.4.0, pyflakes: 2.0.0) CPython 3.7.1 on Darwin
draft $ flake8 f841fail.py
f841fail.py:3:1: F841 local variable 'e' is assigned to but never used
draft $ pip install -U pyflakes
Requirement already up-to-date: pyflakes in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (2.0.0)

In other blocks, the use of locals() prevents F841 from being triggered. It should in exception blocks too.

jaraco added a commit to jaraco/jaraco.mongodb that referenced this issue Oct 26, 2018
@asottile
Copy link
Member

#333 and #343 appear to aim to fix this

jaraco added a commit to jaraco/jaraco.windows that referenced this issue Nov 5, 2018
@jaraco
Copy link
Contributor Author

jaraco commented Nov 5, 2018

Indeed, this looks like a duplicate report.

@jaraco jaraco closed this as completed Nov 5, 2018
jaraco added a commit to jaraco/jaraco.services that referenced this issue Nov 9, 2018
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