PyCQA / PyCQA/flake8

file-level noqa should raise an error if specific errors are provided (to avoid confusion)

Open
#1,793 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3.8k
Forks
356
PR merge metrics
No merged PRs in 30d

Description

how did you install flake8?
pip install flake8
unmodified output of flake8 --bug-report
{
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.10.7",
    "system": "Linux"
  },
  "plugins": [
    {
      "plugin": "mccabe",
      "version": "0.7.0"
    },
    {
      "plugin": "pycodestyle",
      "version": "2.10.0"
    },
    {
      "plugin": "pyflakes",
      "version": "3.0.1"
    }
  ],
  "version": "6.0.0"
}
describe the problem
what I expected to happen

I'm seeing developers using the file-level-noqa ignore wrongly from time to time, providing specific errors like # flake8: noqa: E712. What's confusing is that it gives the impression that it works as it doesn't throw that error anymore but the developers' understanding is incorrect (all errors are ignore). I understood that you don't want to support the file-level-specific-ignores but I think flake8 should do something to prevent this confusion.

See for instance https://til.codeinthehole.com/posts/filelevel-flake8-comments-ignore-all-errors/

My suggestion would be to detect that and throw an error? Somehow it is like providing a flake8 config with a wrong format

sample code
# flake8: noqa: E712

from os import *       # F401
assert True == True # E712

Let me know what you think, happy to work on this if you would welcome a PR

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 locating where Flake8 parses file-level # flake8: noqa comments and where related configuration errors are tested. Reproduce the sample using flake8, then add coverage for a file-level noqa with a specific error code; done means that misuse produces a clear error instead of silently ignoring all errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.