Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b417d57

Browse files
authored
Run flake8-noqa in CI (#8641)
1 parent 1c6eb33 commit b417d57

4 files changed

Lines changed: 24 additions & 16 deletions

File tree

.flake8

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,42 @@
11
# The following rules are incompatible with or enforced by black:
2-
# E203 whitespace before ':' -- scripts only
3-
# E301 expected 1 blank line
4-
# E302 expected 2 blank lines
5-
# E305 expected 2 blank lines
6-
# E501 line too long
2+
# E203 whitespace before ':' -- scripts only
3+
# E301 expected 1 blank line
4+
# E302 expected 2 blank lines
5+
# E305 expected 2 blank lines
6+
# E501 line too long
77

88
# Some rules are considered irrelevant to stub files:
9-
# E701 multiple statements on one line (colon) -- disallows "..." on the same line
10-
# F401 imported but unused -- does not recognize re-exports
9+
# E701 multiple statements on one line (colon) -- disallows "..." on the same line
10+
# F401 imported but unused -- does not recognize re-exports
1111
# https://github.com/PyCQA/pyflakes/issues/474
12-
# F822 undefined name in __all__ -- flake8 does not recognize 'foo: Any'
12+
# F822 undefined name in __all__ -- flake8 does not recognize 'foo: Any'
1313
# https://github.com/PyCQA/pyflakes/issues/533
1414

1515
# Rules that are out of the control of stub authors:
16-
# E741 ambiguous variable name
17-
# F403 import *' used; unable to detect undefined names
18-
# F405 defined from star imports
16+
# E741 ambiguous variable name
17+
# F403 import *' used; unable to detect undefined names
18+
# F405 defined from star imports
1919

2020
# Rules that we'd like to enable in the future:
21-
# Y037 Use PEP 604 syntax instead of `typing.Union` and `typing.Optional`.
21+
# Y037 Use PEP 604 syntax instead of `typing.Union` and `typing.Optional`.
2222
# Currently can't be enabled due to a few lingering bugs in mypy regarding
2323
# PEP 604 type aliases (see #4819).
24+
# NQA102 "noqa" code has no matching violations. We often introduce "noqa" comments
25+
# into the typeshed codebase to unblock flake8-pyi PRs, meaning these comments
26+
# have "no matching violations" since the relevant flake8-pyi checks haven't
27+
# yet been released.
2428

2529
[flake8]
2630
per-file-ignores =
2731
*.py: E203, E301, E302, E305, E501
28-
*.pyi: E301, E302, E305, E501, E701, E741, F401, F403, F405, F822, Y037
32+
*.pyi: E301, E302, E305, E501, E701, E741, NQA102, F401, F403, F405, F822, Y037
2933
# Since typing.pyi defines "overload" this is not recognized by flake8 as typing.overload.
3034
# Unfortunately, flake8 does not allow to "noqa" just a specific error inside the file itself.
3135
# https://github.com/PyCQA/flake8/issues/1079
3236
# F811 redefinition of unused '...'
33-
stdlib/typing.pyi: E301, E302, E305, E501, E701, E741, F401, F403, F405, F811, F822, Y037
37+
stdlib/typing.pyi: E301, E302, E305, E501, E701, E741, NQA102, F401, F403, F405, F811, F822, Y037
3438
# Generated protobuf files include docstrings
35-
*_pb2.pyi: E301, E302, E305, E501, E701, Y021, Y026
39+
*_pb2.pyi: E301, E302, E305, E501, E701, NQA102, Y021, Y026
3640

3741
exclude = .venv*,.git
42+
noqa_require_code = true

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ repos:
2020
- id: flake8
2121
additional_dependencies:
2222
- 'flake8-bugbear==22.7.1' # must match requirements-tests.txt
23+
- 'flake8-noqa==1.2.9' # must match requirements-tests.txt
2324
- 'flake8-pyi==22.8.1' # must match requirements-tests.txt
2425

2526
ci:

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ black .
102102
...Or install the pre-commit hooks: please refer to the
103103
[pre-commit](https://pre-commit.com/) documentation.
104104

105-
Our code is also linted using `flake8`, with plugins `flake8-pyi` and `flake8-bugbear`. As with our other checks, running
105+
Our code is also linted using `flake8`, with plugins `flake8-pyi`,
106+
`flake8-bugbear`, and `flake8-noqa`. As with our other checks, running
106107
flake8 before filing a PR is not required. However, if you wish to run flake8
107108
locally, install the test dependencies as outlined above, and then run:
108109

requirements-tests.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ aiohttp==3.8.1
22
black==22.6.0 # must match .pre-commit-config.yaml
33
flake8==5.0.4 # must match .pre-commit-config.yaml
44
flake8-bugbear==22.7.1 # must match .pre-commit-config.yaml
5+
flake8-noqa==1.2.9 # must match .pre-commit-config.yaml
56
flake8-pyi==22.8.1 # must match .pre-commit-config.yaml
67
isort==5.10.1 # must match .pre-commit-config.yaml
78
mypy==0.971

0 commit comments

Comments
 (0)