1

By default, pylint v2.9.6 gives this warning:

spam.py

"""Docstring."""


def spam():
    """Docstring."""
    spam = 42
    return spam

pylint warning

spam.py|6 col 5 warning| [redefined-outer-name] Redefining name 'spam' from outer scope (line 4) [python/pylint]

After creating the following .pylintrc, the warning is no longer given. This is not desired.

.pylintrc (possible locations)

[VARIABLES]

# A regular expression matching the name of dummy variables (i.e. expected to
# not be used).
#dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
dummy-variables-rgx=

Why?

  • 3
    You have defined *every possible variable name* to be a dummy variable - is that really what you intended? – jasonharper Sep 28 '21 at 14:52
  • Oh, is that the case? No, my intention is have no identifiers be considered dummy variables. What should I do instead? – zatg98n4qwsb8heo Sep 28 '21 at 14:54
  • 1
    That sounds like a bad idea (a dummy variable is exactly what you need, sometimes), but I think `^$` would do the job - that only matches strings with zero length. – jasonharper Sep 28 '21 at 14:59
  • `dummy-variables-rgx=^$` also seems to resolve the error silencing. I'll be defining dummy variables as required, so I will keep your advice in mind. – zatg98n4qwsb8heo Sep 28 '21 at 15:04

0 Answers0