pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.24k stars 1.12k forks source link

False positive: pylint does not honour disable-statement when a line is continued with backslash #9834

Open abaumfalk opened 1 month ago

abaumfalk commented 1 month ago

Bug description

"""
The following code should lint without errors, but pylint shows:
test.py:14:8: E1101: Instance of 'A' has no 'y' member (no-member)
"""
# pylint: disable=too-few-public-methods, pointless-statement

class A:
    """dummy class"""

a = A()
if a.x or \
        a.y:  # pylint: disable=no-member
    pass

Configuration

No response

Command used

pylint test.py

Pylint output

************* Module test
test.py:14:8: E1101: Instance of 'A' has no 'y' member (no-member)

Expected behavior

error should be suppressed because of disable=no-member

Pylint version

pylint 3.2.6
astroid 3.2.4
Python 3.10.12

OS / Environment

$ uname -a Linux xxx 5.15.0-112-generic #122-Ubuntu SMP Thu May 23 07:48:21 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Additional dependencies

No response

Pierre-Sassoulas commented 1 month ago

Is using 'disable-next' on the previous line, instead of the backlash continuation in the actual line, an acceptable workaround ?

abaumfalk commented 1 month ago

Yes, it absolutely is - I was not aware of the disable-next option. Thank you very much!