ruff icon indicating copy to clipboard operation
ruff copied to clipboard

Implement flake8-noqa

Open JonathanPlasse opened this issue 2 years ago • 7 comments

flake8-noqa

Error codes

  • [x] NQA001 "#noqa" must have a single space after the hash, e.g. "# noqa"
  • [x] NQA002 "# noqa X000" must have a colon, e.g. "# noqa: X000"
  • [x] NQA003 "# noqa : X000" must not have a space before the colon, e.g. "# noqa: X000"'
  • [ ] NQA004 "# noqa:  X000" must have at most one space before the codes, e.g. "# noqa: X000"
  • [x] NQA005 "# noqa: X000, X000" has duplicate codes, remove X000
  • [x] NQA101 "# noqa" has no violations
  • [x] NQA102 "# noqa: X000" has no matching violations
  • [x] NQA103 as RUF100 "# noqa: X000, X001" has unmatched code(s), remove X001
  • [x] NQA104 as PGH004 "# noqa" must have codes, e.g. "# noqa: X000" (enable via noqa-require-code)

Flake8 specific rules

Should we ignore them?

  • [ ] NQA011 "#flake8: noqa" must have a single space after the hash, e.g. "# flake8: noqa"
  • [ ] NQA012 "# flake8 noqa" must have a colon or equals, e.g. "# flake8: noqa"
  • [ ] NQA013 "# flake8 : noqa" must not have a space before the colon, e.g. "# flake8: noqa"

Options

  • [x] noqa-require-code as PGH004 : Require code(s) to be included in # noqa comments
  • [x] noqa-no-require-code : Do not require code(s) in # noqa comments (default setting)
  • [ ] noqa-include-name : Include plugin name in messages
  • [ ] noqa-no-include-name : Do not include plugin name in messages (default setting)

JonathanPlasse avatar Nov 21 '22 11:11 JonathanPlasse

We have NQA101, NQA102, and NQA103 as RUF100, but it'd be great to have better diagnostics around noqa validation.

charliermarsh avatar Mar 22 '23 03:03 charliermarsh

NQA001 seems covered by E262

augustelalande avatar Mar 08 '24 21:03 augustelalande

I'm gonna work on NQA002, NQA003, NQA004, and NQA005.

augustelalande avatar Mar 08 '24 22:03 augustelalande

The functionality of NQA002 and NQA003 was added to PGH004

augustelalande avatar Apr 27 '24 04:04 augustelalande

The functionality of NQA005 was added to RUF100

augustelalande avatar Apr 27 '24 17:04 augustelalande

FYI @JonathanPlasse NQA001 and NQA005 should be checked in the summary, but NQA004 should be unchecked for now.

augustelalande avatar Apr 27 '24 17:04 augustelalande

Okay, I think I corrected them.

charliermarsh avatar Apr 27 '24 17:04 charliermarsh