Skip to content

useless-suppression false positive with wrong-import-position #5219

@AChenQ

Description

@AChenQ

Bug description

# pylint: disable=wrong-import-position
"""Test."""
import time

satrt = time.time()

import os

_ = os

Configuration

No response

Command used

pylint a.py --enable=useless-suppression

Pylint output

This message is issued:

$ pylint a.py --enable=useless-suppression
************* Module a
a.py:1:0: I0021: Useless suppression of 'wrong-import-position' (useless-suppression)

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

However, if the comment is removed from line 1, this message is issued:

$ pylint a.py --enable=useless-suppression
************* Module a
a.py:6:0: C0413: Import "import os" should be placed at the top of the module (wrong-import-position)

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

Expected behavior

expect get no useless-suppression message

Pylint version

pylint 2.11.1
astroid 2.8.4
Python 3.7.9 (default, Aug 31 2020, 07:22:35)
[Clang 10.0.0 ]

OS / Environment

macOS

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🪲False Positive 🦟A message is emitted but nothing is wrong with the code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions