Skip to content

Make invalid-name distinguish between module constants and module variables #3585

@bersbersbers

Description

@bersbersbers

Steps to reproduce

  1. pylint bug.py
"""False-positive invalid-name: `variable` is not constant, should not be UPPER_CASE."""
for i in (0, 1, 2):
    variable = i

Current behavior

************* Module cia.bug
bug.py:3:4: C0103: Constant name "variable" doesn't conform to UPPER_CASE naming style (invalid-name)

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

Expected behavior

Perfect score.

pylint --version output

pylint 2.5.0
astroid 2.4.0
Python 3.8.2 (default, Feb 26 2020, 09:52:54) 
[GCC 7.5.0]

Problem does not appear with range(3). Problem does not appear with pylint<2.5.

Metadata

Metadata

Labels

C: invalid-nameEnhancement ✨Improvement to a componentNeeds 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