← Back to team overview

divmod-dev team mailing list archive

[Bug 844592] [NEW] Recognize _("text") from gettext.install(...)

 

Public bug reported:

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?

** Affects: pyflakes
     Importance: Undecided
         Status: New

-- 
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:
  New

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


Follow ups

References