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

Skip to content

Commit 5cb2fe9

Browse files
AvasamAlexWaygood
andauthored
Replace flake8-bugbear with Ruff (#11500)
Co-authored-by: Alex Waygood <[email protected]>
1 parent 791dc91 commit 5cb2fe9

7 files changed

Lines changed: 15 additions & 10 deletions

.flake8

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Since typeshed stubs them, they can still be expected to be found in a
33
# developer's venv for intellisense and reference reasons
44
# A flake8-builtins
5+
# B flake8-bugbear
56
# D flake8-docstrings
67
# N8 pep8-naming
78
# SIM flake8-simplify
@@ -17,7 +18,6 @@
1718
# E701 Multiple statements on one line (colon) -- disallows "..." on the same line
1819

1920
# Some rules are considered irrelevant to stub files:
20-
# B All flake8-bugbear rules are .py-specific
2121
# F401 imported but unused -- does not recognize re-exports
2222
# https://github.com/PyCQA/pyflakes/issues/474
2323

@@ -27,18 +27,18 @@
2727
# F405 defined from star imports
2828

2929
[flake8]
30-
extend-ignore = A, D, N8, SIM, RST, TYP, E301, E302, E305, E501, E701
30+
extend-ignore = A, B, D, N8, SIM, RST, TYP, E301, E302, E305, E501, E701
3131
per-file-ignores =
3232
*.py: E203
33-
*.pyi: B, E741, F401, F403, F405
33+
*.pyi: E741, F401, F403, F405
3434
# Since typing.pyi defines "overload" this is not recognized by Flake8 as typing.overload.
3535
# Unfortunately, Flake8 does not allow to "noqa" just a specific error inside the file itself.
3636
# https://github.com/PyCQA/flake8/issues/1079
3737
# F811 redefinition of unused '...'
38-
stdlib/typing.pyi: B, E741, F401, F403, F405, F811
38+
stdlib/typing.pyi: E741, F401, F403, F405, F811
3939
# Generated protobuf files include docstrings,
4040
# and import some things from typing_extensions that could be imported from typing
41-
*_pb2.pyi: B, E741, F401, F403, F405, Y021, Y023, Y026, Y053, Y054
41+
*_pb2.pyi: E741, F401, F403, F405, Y021, Y023, Y026, Y053, Y054
4242

4343
exclude = .venv*,.git
4444
noqa_require_code = true

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ repos:
2424
hooks:
2525
- id: flake8
2626
additional_dependencies:
27-
- "flake8-bugbear==24.1.17" # must match requirements-tests.txt
2827
- "flake8-noqa==1.4.0" # must match requirements-tests.txt
2928
- "flake8-pyi==24.1.0" # must match requirements-tests.txt
3029
types: [file]

CONTRIBUTING.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ you're free to do so. Either run the following manually...
108108

109109
Our code is also linted using [`Flake8`](https://github.com/pycqa/flake8),
110110
with plugins [`flake8-pyi`](https://github.com/pycqa/flake8-pyi),
111-
[`flake8-bugbear`](https://github.com/PyCQA/flake8-bugbear),
112111
and [`flake8-noqa`](https://github.com/plinss/flake8-noqa).
113112
As with our other checks, running
114113
Flake8 before filing a PR is not required. However, if you wish to run Flake8

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ exclude = [
2525

2626
[tool.ruff.lint]
2727
select = [
28+
"B", # flake8-bugbear
2829
"FA", # flake8-future-annotations
2930
"I", # isort
3031
# Only enable rules that have safe autofixes:
@@ -49,6 +50,13 @@ select = [
4950
"UP039", # don't use parens after a class definition with no bases
5051
]
5152

53+
[tool.ruff.lint.per-file-ignores]
54+
"*.pyi" = [
55+
# Most flake8-bugbear rules don't apply for third-party stubs like typeshed,
56+
# B033 could be slightly useful but Ruff doesn't have per-file select
57+
"B", # flake8-bugbear
58+
]
59+
5260
[tool.ruff.lint.isort]
5361
split-on-trailing-comma = false
5462
combine-as-imports = true

pyrightconfig.testcases.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// See https://github.com/python/typeshed/pull/8083
1616
"enableTypeIgnoreComments": true,
1717
// If a test case uses this anti-pattern, there's likely a reason and annoying to `type: ignore`.
18-
// Let flake8-bugbear flag it (B006)
18+
// Let Ruff flag it (B006)
1919
"reportCallInDefaultInitializer": "none",
2020
// Too strict and not needed for type testing
2121
"reportMissingSuperCall": "none",

requirements-tests.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# "tool.typeshed" section in pyproject.toml for additional type checkers.
44
black==24.1.1 # must match .pre-commit-config.yaml
55
flake8==7.0.0 # must match .pre-commit-config.yaml
6-
flake8-bugbear==24.1.17 # must match .pre-commit-config.yaml
76
flake8-noqa==1.4.0 # must match .pre-commit-config.yaml
87
flake8-pyi==24.1.0 # must match .pre-commit-config.yaml
98
mypy==1.8.0

tests/check_consistent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
# These type checkers and linters must have exact versions in the requirements file to ensure
2525
# consistent CI runs.
26-
linters = {"black", "flake8", "flake8-bugbear", "flake8-noqa", "flake8-pyi", "ruff", "mypy", "pytype"}
26+
linters = {"black", "flake8", "flake8-noqa", "flake8-pyi", "ruff", "mypy", "pytype"}
2727

2828

2929
def assert_consistent_filetypes(

0 commit comments

Comments
 (0)