Pyflakes does not recognize locals() as a use
Bug #872503 reported by
Andrew Schein
This bug affects 2 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Pyflakes |
Fix Released
|
Wishlist
|
Florent |
Bug Description
See attached program for a trivial example of a common idiom:
"my special string %(with_
I wouldn't expect pyflakes to know how to deal with an arbitrary dictionary in the right hand position, but the use of locals() means that certain variables are actually used!
Related branches
lp:~pyflakes-dev/pyflakes/872503-using-locals
- Pyflakes Dev: Pending requested
-
Diff: 74 lines (+28/-0)3 files modifiedNEWS.txt (+1/-0)
pyflakes/checker.py (+5/-0)
pyflakes/test/test_other.py (+22/-0)
tags: | removed: and |
summary: |
- Pyflakes is unable to recognize string substitution as a use + Pyflakes does not recognize locals() as a use |
Changed in pyflakes: | |
assignee: | nobody → Florent (florent.x) |
status: | New → Confirmed |
Changed in pyflakes: | |
status: | Confirmed → In Progress |
Changed in pyflakes: | |
importance: | Undecided → Wishlist |
Changed in pyflakes: | |
status: | In Progress → Fix Committed |
Changed in pyflakes: | |
milestone: | none → 0.6.1 |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
Pyflakes can't be sure that `locals` refers to the builtin locals function which returns the locals of the scope it is used in. It could have been overridden with another object which behaves differently.
Pyflakes could probably track the name and determine if it has been overridden in a sensible way, but there's no way for it to tell if the intended use is for the name to be injected externally somehow.