← Back to team overview

divmod-dev team mailing list archive

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

 

There are plenty of situations where large projects may decide to define
project wide builtins, in order to save having to explicitly import a
frequently used function in every single module. Please consider adding
support for a user specified list of builtin names to ignore, either via
a command line argument or an environment variable.

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