Skip to content

Commit

Permalink
Replace bandit, pylint, flake8 and plugins with ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss committed Mar 9, 2023
1 parent ec0f41b commit 65a93d1
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 110 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codespell-private.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
- uses: codespell-project/sort-problem-matcher@v1
- run: make check-dictionaries

flake8-annotation:
ruff-annotation:
runs-on: ubuntu-latest
steps:
- name: Setup python
Expand All @@ -86,5 +86,5 @@ jobs:
persist-credentials: false
- name: Install codespell dependencies
run: pip install -e ".[dev]"
- name: Flake8 with annotations
uses: TrueBrain/actions-flake8@v2
- name: Ruff with annotations
run: ruff --format=github --select=ANN --ignore=ANN101,ANN401 .
16 changes: 0 additions & 16 deletions .github/workflows/isort.yml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -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 .
43 changes: 10 additions & 33 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,12 @@ repos:
rev: v1.0.1
hooks:
- 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
rev: v4.4.0
hooks:
- id: no-commit-to-branch
args: [--branch, main]
- id: check-toml
- id: check-yaml
args: [--unsafe]
- id: debug-statements
Expand All @@ -59,48 +55,29 @@ repos:
- --no-warnings
- -d
- '{extends: relaxed, rules: {line-length: {max: 90}}}'
- repo: https://github.com/psf/black
rev: 23.1.0
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.254
hooks:
- id: black
- repo: https://github.com/Lucas-C/pre-commit-hooks-bandit
rev: v1.0.6
hooks:
- id: python-bandit-vulnerability-check
- id: ruff
- repo: https://github.com/PyCQA/autoflake
rev: v2.0.1
hooks:
- id: autoflake
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
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
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: isort
- id: black
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
hooks:
- id: codespell
args: [--toml, pyproject-codespell.precommit-toml]
additional_dependencies:
- tomli
- repo: https://github.com/pre-commit/mirrors-pylint
rev: v3.0.0a5
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.12.1
hooks:
- id: pylint
additional_dependencies:
- chardet
- pytest
- id: validate-pyproject
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
hooks:
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ SORT_ARGS := -f -b

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

check: check-dictionaries check-dist flake8 pytest
check: check-dictionaries check-dist pytest ruff

codespell.1: codespell.1.include Makefile
PYTHONPATH=. help2man codespell --include codespell.1.include --no-info --output codespell.1
Expand Down Expand Up @@ -46,8 +46,8 @@ check-dist:
twine check --strict $(TMP)/*
rm -rf $(TMP)

flake8:
flake8
ruff:
ruff .

pytest:
@if command -v pytest > /dev/null; then \
Expand Down
100 changes: 46 additions & 54 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ dynamic = ["version"]
dev = [
"build",
"chardet",
"flake8",
"flake8-pyproject",
"pytest",
"pytest-cov",
"pytest-dependency",
"Pygments",
"ruff",
"tomli"
]
hard-encoding-detection = [
Expand All @@ -64,16 +63,16 @@ homepage = "https://github.com/codespell-project/codespell"
repository = "https://github.com/codespell-project/codespell"

[build-system]
requires = ["setuptools>=64", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=64", "setuptools_scm[toml]>=6.2"]

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

[tool.setuptools.packages.find]
exclude = [
"dist",
"snap",
"dist"
]

[tool.setuptools.package-data]
Expand All @@ -88,67 +87,60 @@ in-place = true
recursive = true
expand-star-imports = true

[tool.bandit]
skip = "B101,B404,B603"
recursive = true

# TODO: reintegrate codespell configuration after updating test cases
#[tool.codespell]
#builtin = ["clear","rare","informal","usage","code","names"]
#ignore-words-list = ["uint"]
#skip=[ "./.*","codespell_lib/data/*","codespell_lib/tests/*"]

[tool.flake8]
max-line-length = "88"
extend-ignore = "E203"

[tool.isort]
profile = "black"

[tool.mypy]
pretty = true
show_error_codes = 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.pytest.ini_options]
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.pylint.FORMAT]
good-names=["F","r","i","n"]
# include-naming-hint=yes
[tool.ruff.mccabe]
max-complexity = 45

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

0 comments on commit 65a93d1

Please sign in to comment.