Skip to content

Commit abd93b0

Browse files
authored
Replace bandit, isort, pylint, pyupgrade, and flake8 plus plugins with ruff (#2779)
1 parent 6b21bb4 commit abd93b0

File tree

6 files changed

+80
-112
lines changed

6 files changed

+80
-112
lines changed

.github/workflows/codespell-private.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
- name: Install dependencies
4242
run: |
4343
python --version # just to check
44-
pip install -U pip wheel # upgrade to latest pip find 3.5 wheels; wheel to avoid errors
44+
pip install --upgrade pip wheel # upgrade to latest pip find 3.5 wheels; wheel to avoid errors
4545
pip install --upgrade "setuptools!=47.2.0" docutils setuptools_scm[toml] twine
4646
pip install aspell-python-py3
4747
pip install -e ".[dev]" # install the codespell dev packages
@@ -68,13 +68,13 @@ jobs:
6868
with:
6969
persist-credentials: false
7070
- name: Install general dependencies
71-
run: pip install -U pip wheel # upgrade to latest pip find 3.5 wheels; wheel to avoid errors
71+
run: pip install --upgrade pip wheel # upgrade to latest pip find 3.5 wheels; wheel to avoid errors
7272
- name: Install codespell dependencies
7373
run: pip install -e ".[dev]"
7474
- uses: codespell-project/sort-problem-matcher@v1
7575
- run: make check-dictionaries
7676

77-
flake8-annotation:
77+
ruff-annotation:
7878
runs-on: ubuntu-latest
7979
steps:
8080
- name: Setup python
@@ -86,5 +86,5 @@ jobs:
8686
persist-credentials: false
8787
- name: Install codespell dependencies
8888
run: pip install -e ".[dev]"
89-
- name: Flake8 with annotations
90-
uses: TrueBrain/actions-flake8@v2
89+
- name: Ruff with annotations
90+
run: ruff --select=ANN --ignore=ANN101,ANN401 .

.github/workflows/isort.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/ruff.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: ruff
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
jobs:
10+
ruff:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- run: pip install --user ruff
15+
- run: ruff --format=github .

.pre-commit-config.yaml

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,12 @@ repos:
2525
rev: v1.0.1
2626
hooks:
2727
- id: rst-linter
28-
- repo: https://github.com/asottile/pyupgrade
29-
rev: v3.3.1
30-
hooks:
31-
- id: pyupgrade
32-
args: [--py37-plus]
3328
- repo: https://github.com/pre-commit/pre-commit-hooks
3429
rev: v4.4.0
3530
hooks:
3631
- id: no-commit-to-branch
3732
args: [--branch, main]
33+
- id: check-toml
3834
- id: check-yaml
3935
args: [--unsafe]
4036
- id: debug-statements
@@ -59,48 +55,29 @@ repos:
5955
- --no-warnings
6056
- -d
6157
- '{extends: relaxed, rules: {line-length: {max: 90}}}'
62-
- repo: https://github.com/psf/black
63-
rev: 23.1.0
58+
- repo: https://github.com/charliermarsh/ruff-pre-commit
59+
rev: v0.0.254
6460
hooks:
65-
- id: black
66-
- repo: https://github.com/Lucas-C/pre-commit-hooks-bandit
67-
rev: v1.0.6
68-
hooks:
69-
- id: python-bandit-vulnerability-check
61+
- id: ruff
7062
- repo: https://github.com/PyCQA/autoflake
7163
rev: v2.0.1
7264
hooks:
7365
- id: autoflake
74-
- repo: https://github.com/PyCQA/flake8
75-
rev: 6.0.0
76-
hooks:
77-
- id: flake8
78-
additional_dependencies:
79-
- flake8-pyproject>=1.2.2
80-
- flake8-bugbear>=22.7.1
81-
- flake8-comprehensions>=3.10.0
82-
- flake8-2020>=1.7.0
83-
- mccabe>=0.7.0
84-
- pycodestyle>=2.9.1
85-
- pyflakes>=2.5.0
86-
- repo: https://github.com/PyCQA/isort
87-
rev: 5.12.0
66+
- repo: https://github.com/psf/black
67+
rev: 23.1.0
8868
hooks:
89-
- id: isort
69+
- id: black
9070
- repo: https://github.com/codespell-project/codespell
9171
rev: v2.2.2
9272
hooks:
9373
- id: codespell
9474
args: [--toml, pyproject-codespell.precommit-toml]
9575
additional_dependencies:
9676
- tomli
97-
- repo: https://github.com/pre-commit/mirrors-pylint
98-
rev: v3.0.0a5
77+
- repo: https://github.com/abravalheri/validate-pyproject
78+
rev: v0.12.1
9979
hooks:
100-
- id: pylint
101-
additional_dependencies:
102-
- chardet
103-
- pytest
80+
- id: validate-pyproject
10481
- repo: https://github.com/pre-commit/mirrors-mypy
10582
rev: v0.991
10683
hooks:

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ SORT_ARGS := -f -b
22

33
DICTIONARIES := codespell_lib/data/dictionary*.txt
44

5-
PHONY := all check check-dictionaries sort-dictionaries trim-dictionaries check-dist flake8 pytest pypi clean
5+
PHONY := all check check-dictionaries sort-dictionaries trim-dictionaries check-dist pytest pypi ruff clean
66

77
all: check-dictionaries codespell.1
88

9-
check: check-dictionaries check-dist flake8 pytest
9+
check: check-dictionaries check-dist pytest ruff
1010

1111
codespell.1: codespell.1.include Makefile
1212
PYTHONPATH=. help2man codespell --include codespell.1.include --no-info --output codespell.1
@@ -46,8 +46,8 @@ check-dist:
4646
twine check --strict $(TMP)/*
4747
rm -rf $(TMP)
4848

49-
flake8:
50-
flake8
49+
ruff:
50+
ruff .
5151

5252
pytest:
5353
@if command -v pytest > /dev/null; then \

pyproject.toml

Lines changed: 46 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@ dynamic = ["version"]
3434
dev = [
3535
"build",
3636
"chardet",
37-
"flake8",
38-
"flake8-pyproject",
3937
"pytest",
4038
"pytest-cov",
4139
"pytest-dependency",
4240
"Pygments",
41+
"ruff",
4342
"tomli"
4443
]
4544
hard-encoding-detection = [
@@ -64,16 +63,16 @@ homepage = "https://github.com/codespell-project/codespell"
6463
repository = "https://github.com/codespell-project/codespell"
6564

6665
[build-system]
67-
requires = ["setuptools>=64", "setuptools_scm[toml]>=6.2"]
6866
build-backend = "setuptools.build_meta"
67+
requires = ["setuptools>=64", "setuptools_scm[toml]>=6.2"]
6968

7069
[tool.setuptools_scm]
7170
write_to = "codespell_lib/_version.py"
7271

7372
[tool.setuptools.packages.find]
7473
exclude = [
74+
"dist",
7575
"snap",
76-
"dist"
7776
]
7877

7978
[tool.setuptools.package-data]
@@ -88,67 +87,60 @@ in-place = true
8887
recursive = true
8988
expand-star-imports = true
9089

91-
[tool.bandit]
92-
skip = "B101,B404,B603"
93-
recursive = true
94-
9590
# TODO: reintegrate codespell configuration after updating test cases
9691
#[tool.codespell]
9792
#builtin = ["clear","rare","informal","usage","code","names"]
9893
#ignore-words-list = ["uint"]
9994
#skip=[ "./.*","codespell_lib/data/*","codespell_lib/tests/*"]
10095

101-
[tool.flake8]
102-
max-line-length = "88"
103-
extend-ignore = "E203"
104-
105-
[tool.isort]
106-
profile = "black"
107-
10896
[tool.mypy]
10997
pretty = true
11098
show_error_codes = true
11199
strict = true
112100

113-
[tool.pylint]
114-
reports=false
115-
py-version="3.7"
116-
disable = [
117-
"broad-except",
118-
"consider-using-f-string",
119-
"consider-using-dict-items",
120-
"consider-using-with",
121-
"fixme",
122-
"import-error",
123-
"import-outside-toplevel",
124-
"invalid-name",
125-
"line-too-long",
126-
"missing-class-docstring",
127-
"missing-module-docstring",
128-
"missing-function-docstring",
129-
"no-else-raise",
130-
"no-else-return",
131-
"raise-missing-from",
132-
"redefined-outer-name",
133-
"subprocess-run-check",
134-
"too-many-arguments",
135-
"too-many-lines",
136-
"too-many-locals",
137-
"too-many-branches",
138-
"too-many-statements",
139-
"too-many-return-statements",
140-
"too-few-public-methods",
141-
"unneeded-not",
142-
"unspecified-encoding",
143-
"unused-argument",
144-
"unused-variable",
145-
"use-maxsplit-arg"
146-
]
101+
[tool.pytest.ini_options]
102+
addopts = "--cov=codespell_lib -rs --cov-report= --tb=short --junit-xml=junit-results.xml"
147103

104+
[tool.ruff]
105+
extend-ignore = [
106+
"A003",
107+
"ANN101",
108+
"ANN401",
109+
"B904",
110+
"N802",
111+
"N812",
112+
"PLW2901",
113+
"S101",
114+
"UP031",
115+
]
116+
line-length = 88
117+
select = [
118+
"A",
119+
"ANN",
120+
"B",
121+
"C4",
122+
"C9",
123+
"E",
124+
"F",
125+
"I",
126+
"N",
127+
"PLC",
128+
"PLE",
129+
"PLR",
130+
"PLW",
131+
"S",
132+
"U",
133+
"W",
134+
"YTT",
135+
]
136+
target-version = "py37"
148137

149-
[tool.pylint.FORMAT]
150-
good-names=["F","r","i","n"]
151-
# include-naming-hint=yes
138+
[tool.ruff.mccabe]
139+
max-complexity = 45
152140

153-
[tool.pytest.ini_options]
154-
addopts = "--cov=codespell_lib -rs --cov-report= --tb=short --junit-xml=junit-results.xml"
141+
[tool.ruff.pylint]
142+
allow-magic-value-types = ["bytes", "int", "str",]
143+
max-args = 12
144+
max-branches = 48
145+
max-returns = 10
146+
max-statements = 111

0 commit comments

Comments
 (0)