divmod-dev team mailing list archive
-
divmod-dev team
-
Mailing list archive
-
Message #00132
[Bug 844592] Re: Recognize _("text") from gettext.install(...)
The difference isn't really relevant to Pyflakes. The example I gave
was meant to be a trivial example of how you can apply the solution. If
you want a different gettext function to be bound to _, you can have a
different gettext function bound to _. If you want unicode, use
gettext.ugettext. If you want a particular domain, use the
gettext.translation function to get an instance of something for the
appropriate domain and then use that object's gettext method. etc.
--
You received this bug notification because you are a member of Divmod-
dev, which is the registrant for Pyflakes.
https://bugs.launchpad.net/bugs/844592
Title:
Recognize _("text") from gettext.install(...)
Status in Pyflakes:
Won't Fix
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.install(...)
#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?
To manage notifications about this bug go to:
https://bugs.launchpad.net/pyflakes/+bug/844592/+subscriptions
References