Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable-next leaks into the whole block if it's followed by an empty line #7401

Closed
Jackenmen opened this issue Sep 2, 2022 · 0 comments · Fixed by #7411
Closed

disable-next leaks into the whole block if it's followed by an empty line #7401

Jackenmen opened this issue Sep 2, 2022 · 0 comments · Fixed by #7411
Assignees
Labels
Bug 🪲 C: Pragma's Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@Jackenmen
Copy link
Contributor

Jackenmen commented Sep 2, 2022

Bug description

  1. Create a virtual environment (e.g. run virtualenv pylint-repro)
  2. Activate the virtual environment (e.g. run . pylint-repro/bin/activate
  3. Install pylint (e.g. pip install pylint)
  4. Put these contents into an example.py file:
# pylint: disable=missing-docstring


def func():
    # pylint: disable-next=unused-variable

    test = 43
    blah = 123
  1. Run pylint example.py
  2. See the issue.

Configuration

No response

Command used

pylint example.py

Pylint output

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

Expected behavior

I expected the second unused variable to be reported, as is the case when not putting an empty line between disable-next and the line I'm suppressing errors for:

# pylint: disable=missing-docstring


def func():
    # pylint: disable-next=unused-variable
    test = 43
    blah = 123

Example output:

************* Module example
example.py:7:4: W0612: Unused variable 'blah' (unused-variable)

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

It probably would also be fine if an empty line between the comment and line to suppress simply didn't work. My issue is that this appears to do what I've intended - it suppresses the unused variable for next line - but it also does things it wasn't supposed to.

Pylint version

pylint 2.15.0
astroid 2.12.5
Python 3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0]

OS / Environment

Ubuntu 22.04.1, Python 3.10 shipped with the system

Additional dependencies

No response

@Jackenmen Jackenmen added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Sep 2, 2022
@DanielNoord DanielNoord added Bug 🪲 C: Pragma's Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Sep 2, 2022
@DanielNoord DanielNoord added this to the 2.15.1 milestone Sep 5, 2022
@DanielNoord DanielNoord self-assigned this Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 C: Pragma's Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants