Skip to content

unused-import should observe dummy-variables-rgx setting #8500

@macdjord

Description

@macdjord

Bug description

Python convention is that any variable name consisting entirely of underscores is to be considered a placeholder, used when a value needs to be assigned somewhere but you don't actually care about it after that. Thus no warnings should be emitted about such a variable being unused, overwritten, or changing type.

However, another common convention is to import the gettext() translation function as _ for convenience. Thus current best-practice is to use names of two or more underscores for placeholders.

test2.py:

"""Test"""

import prettyprinter as __

Configuration

No response

Command used

pylint test2.py

Pylint output

************* Module test2
test2.py:3:0: W0611: Unused prettyprinter imported as __ (unused-import)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

Expected behavior

No unused-import should be emitted if the module is imported with a name consisting entirely of underscores.

Pylint version

pylint 2.16.2
astroid 2.14.2
Python 3.11.2 (tags/v3.11.2:878ead1, Feb  7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)]

OS / Environment

Win10

Additional dependencies

No response

Metadata

Metadata

Assignees

Labels

Enhancement ✨Improvement to a componentGood first issueFriendly and approachable by new contributorsHelp wanted 🙏Outside help would be appreciated, good for new contributorsNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions