Skip to content

Pylint disable working incorrectly #7625

@DanJBower

Description

@DanJBower

Bug description

When using pylint: disable-next or pylint: disable for a comment that violates the rule, it disables the rule for the whole file instead of just the line

Not working

# pylint: disable-next=C0301
# This line is too long. A line should be less than 100 characters but this is 109 characters and that is bad

def testMethod():
    print('This line is too long. A line should be less than 100 characters but this is 120 characters and that is bad')

Not working

# This line is too long. A line should be less than 100 characters but this is 109 characters and that is bad # pylint: disable=C0301

def testMethod():
    print('This line is too long. A line should be less than 100 characters but this is 120 characters and that is bad')

Working

# pylint: disable-next=C0301
# This line is too long. A line should be less than 100 characters but this is 109 characters and that is bad

# pylint: enable=C0301
def testMethod():
    print('This line is too long. A line should be less than 100 characters but this is 120 characters and that is bad')

Whilst above works, I think it is a bug that I have to manually re-enable the rule

Configuration

No response

Command used

pylint Test.py --disable R,C,W,E --enable C0301

Pylint output

--------------------------------------------------------------------
Your code has been rated at 10.00/10

Expected behavior

************* Module Test
Test.py:5:0: C0301: Line too long (120/100) (line-too-long)


Your code has been rated at 5.00/10

Pylint version

pylint 2.14.5
astroid 2.11.7
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)]

OS / Environment

Windows 10 20H2

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions