Skip to content

Commit

Permalink
Move back to flake8, remove ruff
Browse files Browse the repository at this point in the history
Choice of linter toolchain is a matter for project developers. `ruff`
was pushed by an external contributor, and was accepted to hopefully
improve interest/engagement in maintenance.

However, there was no particular reason to use `ruff` and it puts us
in the position of opting out of a lot of configs rather than opting
in to what we want.

flake8 also offers a plugin framework which allows for checks like
`flake8-typing-as-t` to be easily added post-hoc.

In addition to flake8, reapply isort and pyupgrade, and add slyp.
  • Loading branch information
sirosen committed Dec 22, 2023
1 parent 2291740 commit 7c6d54f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 88 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
exclude = .git,.tox,__pycache__,.eggs,dist,.venv*,docs,build
max-line-length = 88
extend-ignore = W503,W504,E203
29 changes: 21 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,33 @@ repos:
hooks:
- id: black
language_version: python3
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: ["--py37-plus"]
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies:
- 'flake8-bugbear==23.9.16'
- 'flake8-comprehensions==3.14.0'
- 'flake8-typing-as-t==0.0.3'
- repo: https://github.com/sirosen/slyp
rev: 0.1.2
hooks:
- id: slyp
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
hooks:
- id: codespell
additional_dependencies:
- tomli
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.291
hooks:
- id: ruff
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.14
hooks:
- id: validate-pyproject
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 1.2.0
hooks:
Expand Down
83 changes: 3 additions & 80 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,83 +59,6 @@ nose2 = "nose2:discover"
[tool.setuptools.dynamic]
version = {attr = "nose2.__version__"}

[tool.ruff]
select = [
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"C90", # McCabe cyclomatic complexity
"E", # pycodestyle
"EXE", # flake8-executable
"F", # Pyflakes
"I", # isort
"ICN", # flake8-import-conventions
"INT", # flake8-gettext
"PLE", # Pylint errors
"PLR091", # Pylint Refactor just for max-args, max-branches, etc.
"PYI", # flake8-pyi
"RSE", # flake8-raise
"RUF", # Ruff-specific rules
"TCH", # flake8-type-checking
"TID", # flake8-tidy-imports
"UP", # pyupgrade
"W", # pycodestyle
"YTT", # flake8-2020
# "A", # flake8-builtins
# "ANN", # flake8-annotations
# "ARG", # flake8-unused-arguments
# "BLE", # flake8-blind-except
# "COM", # flake8-commas
# "D", # pydocstyle
# "DJ", # flake8-django
# "DTZ", # flake8-datetimez
# "EM", # flake8-errmsg
# "ERA", # eradicate
# "FBT", # flake8-boolean-trap
# "G", # flake8-logging-format
# "INP", # flake8-no-pep420
# "ISC", # flake8-implicit-str-concat
# "N", # pep8-naming
# "NPY", # NumPy-specific rules
# "PD", # pandas-vet
# "PGH", # pygrep-hooks
# "PIE", # flake8-pie
# "PT", # flake8-pytest-style
# "PTH", # flake8-use-pathlib
# "Q", # flake8-quotes
# "RET", # flake8-return
# "S", # flake8-bandit
# "SIM", # flake8-simplify
# "SLF", # flake8-self
# "T10", # flake8-debugger
# "T20", # flake8-print
# "TRY", # tryceratops
]
ignore = [
"B904",
"RUF005",
"RUF012",
"RUF100"
]
target-version = "py37"

[tool.ruff.isort]
known-third-party = [
"coverage",
"mock",
]

[tool.ruff.mccabe]
max-complexity = 15

[tool.ruff.pylint]
max-args = 9
max-branches = 15
max-statements = 66

[tool.ruff.per-file-ignores]
"nose2/tests/*" = ["B011"]
# FIXME: resolving these could change behavior -- do it in a separate
# cleanup and note it in the changelog
"nose2/plugins/loader/*.py" = ["B004"]
"nose2/plugins/mp.py" = ["UP031"]
"nose2/tests/functional/support/such/test_regression_same_havings.py" = ["EXE001"]
[tool.isort]
profile = "black"
known_third_party = ["coverage", "mock"]

0 comments on commit 7c6d54f

Please sign in to comment.