Skip to content

pylint disable= directives ignored for comments following the last statement in a file #1681

@funous

Description

@funous

Steps to reproduce

  1. Run a fresh installation of ubuntu with pylint to rule out any user-specific configuration:
docker run -ti ubuntu:16.04 /bin/bash
apt-get update
apt install python3-pip
pip3 install pylint
  1. Create a file test.py that contains a TODO comment with a pylint: disable=fixme directive after the last statement in the file, such as this one:
# TODO: todo1 # pylint: disable=fixme
# TODO: todo2 # pylint: disable=fixme


def foo():
    return 1

# TODO: todo3 # pylint: disable=fixme
# TODO: todo4 # pylint: disable=fixme
  1. Run pylint against it: pylint test.py

Current behavior

Fixme comments on line 8 and 9 are not ignored.

root@c12a41fffb0e:/# pylint test2.py
No config file found, using default configuration
************* Module test2
W:  8, 0: TODO: todo3 # pylint: disable=fixme (fixme)
W:  9, 0: TODO: todo4 # pylint: disable=fixme (fixme)
C:  1, 0: Missing module docstring (missing-docstring)
C:  5, 0: Black listed name "foo" (blacklisted-name)
C:  5, 0: Missing function docstring (missing-docstring)

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

Expected behavior

No fixme warnings for lines 8 and 9 - essentially the same output as if pylint --disable=fixme test2.py was used.

pylint --version output

No config file found, using default configuration
pylint 1.7.2,
astroid 1.5.3
Python 3.5.2 (default, Aug 18 2017, 17:48:00)
[GCC 5.4.0 20160609]

Using #pragma pylint: disable=fixme at the top of the file doesn't solve the issue. Using --enable=useless-suppression actually causes this to be added to the output:

I:  8, 0: Useless suppression of 'fixme' (useless-suppression)
I:  9, 0: Useless suppression of 'fixme' (useless-suppression)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions