mirror of
https://github.com/codespell-project/codespell.git
synced 2025-08-06 09:40:56 +08:00
Replace bandit, isort, pylint, pyupgrade, and flake8 plus plugins with ruff (#2779)
This commit is contained in:
10
.github/workflows/codespell-private.yml
vendored
10
.github/workflows/codespell-private.yml
vendored
@ -41,7 +41,7 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python --version # just to check
|
python --version # just to check
|
||||||
pip install -U pip wheel # upgrade to latest pip find 3.5 wheels; wheel to avoid errors
|
pip install --upgrade pip wheel # upgrade to latest pip find 3.5 wheels; wheel to avoid errors
|
||||||
pip install --upgrade "setuptools!=47.2.0" docutils setuptools_scm[toml] twine
|
pip install --upgrade "setuptools!=47.2.0" docutils setuptools_scm[toml] twine
|
||||||
pip install aspell-python-py3
|
pip install aspell-python-py3
|
||||||
pip install -e ".[dev]" # install the codespell dev packages
|
pip install -e ".[dev]" # install the codespell dev packages
|
||||||
@ -68,13 +68,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
- name: Install general dependencies
|
- name: Install general dependencies
|
||||||
run: pip install -U pip wheel # upgrade to latest pip find 3.5 wheels; wheel to avoid errors
|
run: pip install --upgrade pip wheel # upgrade to latest pip find 3.5 wheels; wheel to avoid errors
|
||||||
- name: Install codespell dependencies
|
- name: Install codespell dependencies
|
||||||
run: pip install -e ".[dev]"
|
run: pip install -e ".[dev]"
|
||||||
- uses: codespell-project/sort-problem-matcher@v1
|
- uses: codespell-project/sort-problem-matcher@v1
|
||||||
- run: make check-dictionaries
|
- run: make check-dictionaries
|
||||||
|
|
||||||
flake8-annotation:
|
ruff-annotation:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Setup python
|
- name: Setup python
|
||||||
@ -86,5 +86,5 @@ jobs:
|
|||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
- name: Install codespell dependencies
|
- name: Install codespell dependencies
|
||||||
run: pip install -e ".[dev]"
|
run: pip install -e ".[dev]"
|
||||||
- name: Flake8 with annotations
|
- name: Ruff with annotations
|
||||||
uses: TrueBrain/actions-flake8@v2
|
run: ruff --select=ANN --ignore=ANN101,ANN401 .
|
||||||
|
16
.github/workflows/isort.yml
vendored
16
.github/workflows/isort.yml
vendored
@ -1,16 +0,0 @@
|
|||||||
name: isort
|
|
||||||
|
|
||||||
on:
|
|
||||||
- push
|
|
||||||
- pull_request
|
|
||||||
|
|
||||||
permissions: {}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
isort:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- uses: isort/isort-action@v1
|
|
15
.github/workflows/ruff.yml
vendored
Normal file
15
.github/workflows/ruff.yml
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
name: ruff
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
jobs:
|
||||||
|
ruff:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- run: pip install --user ruff
|
||||||
|
- run: ruff --format=github .
|
@ -25,16 +25,12 @@ repos:
|
|||||||
rev: v1.0.1
|
rev: v1.0.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: rst-linter
|
- id: rst-linter
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
|
||||||
rev: v3.3.1
|
|
||||||
hooks:
|
|
||||||
- id: pyupgrade
|
|
||||||
args: [--py37-plus]
|
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v4.4.0
|
rev: v4.4.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: no-commit-to-branch
|
- id: no-commit-to-branch
|
||||||
args: [--branch, main]
|
args: [--branch, main]
|
||||||
|
- id: check-toml
|
||||||
- id: check-yaml
|
- id: check-yaml
|
||||||
args: [--unsafe]
|
args: [--unsafe]
|
||||||
- id: debug-statements
|
- id: debug-statements
|
||||||
@ -59,34 +55,18 @@ repos:
|
|||||||
- --no-warnings
|
- --no-warnings
|
||||||
- -d
|
- -d
|
||||||
- '{extends: relaxed, rules: {line-length: {max: 90}}}'
|
- '{extends: relaxed, rules: {line-length: {max: 90}}}'
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
||||||
rev: 23.1.0
|
rev: v0.0.254
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: ruff
|
||||||
- repo: https://github.com/Lucas-C/pre-commit-hooks-bandit
|
|
||||||
rev: v1.0.6
|
|
||||||
hooks:
|
|
||||||
- id: python-bandit-vulnerability-check
|
|
||||||
- repo: https://github.com/PyCQA/autoflake
|
- repo: https://github.com/PyCQA/autoflake
|
||||||
rev: v2.0.1
|
rev: v2.0.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: autoflake
|
- id: autoflake
|
||||||
- repo: https://github.com/PyCQA/flake8
|
- repo: https://github.com/psf/black
|
||||||
rev: 6.0.0
|
rev: 23.1.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: black
|
||||||
additional_dependencies:
|
|
||||||
- flake8-pyproject>=1.2.2
|
|
||||||
- flake8-bugbear>=22.7.1
|
|
||||||
- flake8-comprehensions>=3.10.0
|
|
||||||
- flake8-2020>=1.7.0
|
|
||||||
- mccabe>=0.7.0
|
|
||||||
- pycodestyle>=2.9.1
|
|
||||||
- pyflakes>=2.5.0
|
|
||||||
- repo: https://github.com/PyCQA/isort
|
|
||||||
rev: 5.12.0
|
|
||||||
hooks:
|
|
||||||
- id: isort
|
|
||||||
- repo: https://github.com/codespell-project/codespell
|
- repo: https://github.com/codespell-project/codespell
|
||||||
rev: v2.2.2
|
rev: v2.2.2
|
||||||
hooks:
|
hooks:
|
||||||
@ -94,13 +74,10 @@ repos:
|
|||||||
args: [--toml, pyproject-codespell.precommit-toml]
|
args: [--toml, pyproject-codespell.precommit-toml]
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
- tomli
|
- tomli
|
||||||
- repo: https://github.com/pre-commit/mirrors-pylint
|
- repo: https://github.com/abravalheri/validate-pyproject
|
||||||
rev: v3.0.0a5
|
rev: v0.12.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: pylint
|
- id: validate-pyproject
|
||||||
additional_dependencies:
|
|
||||||
- chardet
|
|
||||||
- pytest
|
|
||||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||||
rev: v0.991
|
rev: v0.991
|
||||||
hooks:
|
hooks:
|
||||||
|
8
Makefile
8
Makefile
@ -2,11 +2,11 @@ SORT_ARGS := -f -b
|
|||||||
|
|
||||||
DICTIONARIES := codespell_lib/data/dictionary*.txt
|
DICTIONARIES := codespell_lib/data/dictionary*.txt
|
||||||
|
|
||||||
PHONY := all check check-dictionaries sort-dictionaries trim-dictionaries check-dist flake8 pytest pypi clean
|
PHONY := all check check-dictionaries sort-dictionaries trim-dictionaries check-dist pytest pypi ruff clean
|
||||||
|
|
||||||
all: check-dictionaries codespell.1
|
all: check-dictionaries codespell.1
|
||||||
|
|
||||||
check: check-dictionaries check-dist flake8 pytest
|
check: check-dictionaries check-dist pytest ruff
|
||||||
|
|
||||||
codespell.1: codespell.1.include Makefile
|
codespell.1: codespell.1.include Makefile
|
||||||
PYTHONPATH=. help2man codespell --include codespell.1.include --no-info --output codespell.1
|
PYTHONPATH=. help2man codespell --include codespell.1.include --no-info --output codespell.1
|
||||||
@ -46,8 +46,8 @@ check-dist:
|
|||||||
twine check --strict $(TMP)/*
|
twine check --strict $(TMP)/*
|
||||||
rm -rf $(TMP)
|
rm -rf $(TMP)
|
||||||
|
|
||||||
flake8:
|
ruff:
|
||||||
flake8
|
ruff .
|
||||||
|
|
||||||
pytest:
|
pytest:
|
||||||
@if command -v pytest > /dev/null; then \
|
@if command -v pytest > /dev/null; then \
|
||||||
|
102
pyproject.toml
102
pyproject.toml
@ -34,12 +34,11 @@ dynamic = ["version"]
|
|||||||
dev = [
|
dev = [
|
||||||
"build",
|
"build",
|
||||||
"chardet",
|
"chardet",
|
||||||
"flake8",
|
|
||||||
"flake8-pyproject",
|
|
||||||
"pytest",
|
"pytest",
|
||||||
"pytest-cov",
|
"pytest-cov",
|
||||||
"pytest-dependency",
|
"pytest-dependency",
|
||||||
"Pygments",
|
"Pygments",
|
||||||
|
"ruff",
|
||||||
"tomli"
|
"tomli"
|
||||||
]
|
]
|
||||||
hard-encoding-detection = [
|
hard-encoding-detection = [
|
||||||
@ -64,16 +63,16 @@ homepage = "https://github.com/codespell-project/codespell"
|
|||||||
repository = "https://github.com/codespell-project/codespell"
|
repository = "https://github.com/codespell-project/codespell"
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["setuptools>=64", "setuptools_scm[toml]>=6.2"]
|
|
||||||
build-backend = "setuptools.build_meta"
|
build-backend = "setuptools.build_meta"
|
||||||
|
requires = ["setuptools>=64", "setuptools_scm[toml]>=6.2"]
|
||||||
|
|
||||||
[tool.setuptools_scm]
|
[tool.setuptools_scm]
|
||||||
write_to = "codespell_lib/_version.py"
|
write_to = "codespell_lib/_version.py"
|
||||||
|
|
||||||
[tool.setuptools.packages.find]
|
[tool.setuptools.packages.find]
|
||||||
exclude = [
|
exclude = [
|
||||||
|
"dist",
|
||||||
"snap",
|
"snap",
|
||||||
"dist"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.setuptools.package-data]
|
[tool.setuptools.package-data]
|
||||||
@ -88,67 +87,60 @@ in-place = true
|
|||||||
recursive = true
|
recursive = true
|
||||||
expand-star-imports = true
|
expand-star-imports = true
|
||||||
|
|
||||||
[tool.bandit]
|
|
||||||
skip = "B101,B404,B603"
|
|
||||||
recursive = true
|
|
||||||
|
|
||||||
# TODO: reintegrate codespell configuration after updating test cases
|
# TODO: reintegrate codespell configuration after updating test cases
|
||||||
#[tool.codespell]
|
#[tool.codespell]
|
||||||
#builtin = ["clear","rare","informal","usage","code","names"]
|
#builtin = ["clear","rare","informal","usage","code","names"]
|
||||||
#ignore-words-list = ["uint"]
|
#ignore-words-list = ["uint"]
|
||||||
#skip=[ "./.*","codespell_lib/data/*","codespell_lib/tests/*"]
|
#skip=[ "./.*","codespell_lib/data/*","codespell_lib/tests/*"]
|
||||||
|
|
||||||
[tool.flake8]
|
|
||||||
max-line-length = "88"
|
|
||||||
extend-ignore = "E203"
|
|
||||||
|
|
||||||
[tool.isort]
|
|
||||||
profile = "black"
|
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
pretty = true
|
pretty = true
|
||||||
show_error_codes = true
|
show_error_codes = true
|
||||||
strict = true
|
strict = true
|
||||||
|
|
||||||
[tool.pylint]
|
|
||||||
reports=false
|
|
||||||
py-version="3.7"
|
|
||||||
disable = [
|
|
||||||
"broad-except",
|
|
||||||
"consider-using-f-string",
|
|
||||||
"consider-using-dict-items",
|
|
||||||
"consider-using-with",
|
|
||||||
"fixme",
|
|
||||||
"import-error",
|
|
||||||
"import-outside-toplevel",
|
|
||||||
"invalid-name",
|
|
||||||
"line-too-long",
|
|
||||||
"missing-class-docstring",
|
|
||||||
"missing-module-docstring",
|
|
||||||
"missing-function-docstring",
|
|
||||||
"no-else-raise",
|
|
||||||
"no-else-return",
|
|
||||||
"raise-missing-from",
|
|
||||||
"redefined-outer-name",
|
|
||||||
"subprocess-run-check",
|
|
||||||
"too-many-arguments",
|
|
||||||
"too-many-lines",
|
|
||||||
"too-many-locals",
|
|
||||||
"too-many-branches",
|
|
||||||
"too-many-statements",
|
|
||||||
"too-many-return-statements",
|
|
||||||
"too-few-public-methods",
|
|
||||||
"unneeded-not",
|
|
||||||
"unspecified-encoding",
|
|
||||||
"unused-argument",
|
|
||||||
"unused-variable",
|
|
||||||
"use-maxsplit-arg"
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
[tool.pylint.FORMAT]
|
|
||||||
good-names=["F","r","i","n"]
|
|
||||||
# include-naming-hint=yes
|
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
addopts = "--cov=codespell_lib -rs --cov-report= --tb=short --junit-xml=junit-results.xml"
|
addopts = "--cov=codespell_lib -rs --cov-report= --tb=short --junit-xml=junit-results.xml"
|
||||||
|
|
||||||
|
[tool.ruff]
|
||||||
|
extend-ignore = [
|
||||||
|
"A003",
|
||||||
|
"ANN101",
|
||||||
|
"ANN401",
|
||||||
|
"B904",
|
||||||
|
"N802",
|
||||||
|
"N812",
|
||||||
|
"PLW2901",
|
||||||
|
"S101",
|
||||||
|
"UP031",
|
||||||
|
]
|
||||||
|
line-length = 88
|
||||||
|
select = [
|
||||||
|
"A",
|
||||||
|
"ANN",
|
||||||
|
"B",
|
||||||
|
"C4",
|
||||||
|
"C9",
|
||||||
|
"E",
|
||||||
|
"F",
|
||||||
|
"I",
|
||||||
|
"N",
|
||||||
|
"PLC",
|
||||||
|
"PLE",
|
||||||
|
"PLR",
|
||||||
|
"PLW",
|
||||||
|
"S",
|
||||||
|
"U",
|
||||||
|
"W",
|
||||||
|
"YTT",
|
||||||
|
]
|
||||||
|
target-version = "py37"
|
||||||
|
|
||||||
|
[tool.ruff.mccabe]
|
||||||
|
max-complexity = 45
|
||||||
|
|
||||||
|
[tool.ruff.pylint]
|
||||||
|
allow-magic-value-types = ["bytes", "int", "str",]
|
||||||
|
max-args = 12
|
||||||
|
max-branches = 48
|
||||||
|
max-returns = 10
|
||||||
|
max-statements = 111
|
||||||
|
Reference in New Issue
Block a user