PyCQA / PyCQA/flake8

Raise errors when "# noqa" lines don't have any issues

Open
#603 9 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature:accepted priority:medium
Dominant language
Python
Stars
3.8k
Forks
356
PR merge metrics
No merged PRs in 30d

Description

In GitLab by @OddBloke on Jul 27, 2017, 06:27

Please describe how you installed Flake8

On Ubuntu Artful:

$ apt install flake8

Please provide the exact, unmodified output of flake8 --bug-report

{
  "dependencies": [
    {
      "dependency": "setuptools",
      "version": "36.0.1"
    }
  ],
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.5.3+",
    "system": "Linux"
  },
  "plugins": [
    {
      "plugin": "mccabe",
      "version": "0.6.1"
    },
    {
      "plugin": "pycodestyle",
      "version": "2.3.1"
    },
    {
      "plugin": "pyflakes",
      "version": "1.5.0"
    }
  ],
  "version": "3.2.1"
}

Please describe the problem or feature

I would like to be able to instruct flake8 to error out when a "# noqa" comment doesn't cause an error to be ignored. This would help us keep our codebase as flake'd as possible, because we'd be forced to remove linting ignores as they are fixed or become irrelevant.

As a specific example, we have code which currently causes an F401 because the imports are only used in Python typing comments. A reductive case:

from typing import Optional  # noqa: F401

def foo():
    # type: () -> Optional[int]
    ...

Once #118 has been addressed, this line should no longer be raising an F401, so I would like to be forced to remove the noqa comment. (This would then mean, after the removal, that we would correctly catch the addition of unused typing imports.)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing Flake8's handling of # noqa comments and how ignored violations are reported, using the typing-comment example as a concrete case. Done means Flake8 errors when a # noqa comment suppresses no issue, while valid suppressions continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.