Recognize _("text") from gettext.install(...)
Bug #844592 reported by
Dima Tisnek
This bug affects 3 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Pyflakes |
Fix Released
|
Wishlist
|
Unassigned |
Bug Description
gettext module provides convenience function gettext.install() that injects a callable _ [single underscore] into builtins, so that internationalized code can be written like this:
print _("text")
pyflakes reports every _ as undefined symbol.
moreover since it is injected in builtins, all imported modules have that symbol, thus the following works:
# main.py
import gettext
import somemod
gettext.
#somemod.py
print _("text")
I'm not sure what sort of heuristic could be used to recognize _() when pyflake checks somemod.py.
Perhaps a command line argument for extra builtins?
Related branches
lp:~pyflakes-dev/pyflakes/1172130-doctest-syntax-error
- Pyflakes Dev: Pending requested
-
Diff: 203 lines (+80/-20) (has conflicts)5 files modifiedNEWS.txt (+12/-1)
pyflakes/__init__.py (+4/-0)
pyflakes/checker.py (+24/-12)
pyflakes/messages.py (+3/-1)
pyflakes/test/test_doctests.py (+37/-6)
Changed in pyflakes: | |
milestone: | none → 0.7.x |
status: | Confirmed → In Progress |
Changed in pyflakes: | |
milestone: | 0.7.x → 0.7.2 |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
Instead of using the injected builtins feature of gettext, import the name. Then both pyflakes and human readers of the code will know what's going on.
from gettext import gettext as _