diff --git a/.github/workflows/codespell-private.yml b/.github/workflows/codespell-private.yml index 1318451862..f6cda80f5e 100644 --- a/.github/workflows/codespell-private.yml +++ b/.github/workflows/codespell-private.yml @@ -41,7 +41,7 @@ jobs: - name: Install dependencies run: | 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 aspell-python-py3 pip install -e ".[dev]" # install the codespell dev packages @@ -68,13 +68,13 @@ jobs: with: persist-credentials: false - 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 run: pip install -e ".[dev]" - uses: codespell-project/sort-problem-matcher@v1 - run: make check-dictionaries - flake8-annotation: + ruff-annotation: runs-on: ubuntu-latest steps: - name: Setup python @@ -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 --select=ANN --ignore=ANN101,ANN401 . diff --git a/.github/workflows/isort.yml b/.github/workflows/isort.yml deleted file mode 100644 index 0919f7eae8..0000000000 --- a/.github/workflows/isort.yml +++ /dev/null @@ -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 diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml new file mode 100644 index 0000000000..a11f951446 --- /dev/null +++ b/.github/workflows/ruff.yml @@ -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 . diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 018858e8d7..a84ea01b01 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -59,34 +55,18 @@ 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: @@ -94,13 +74,10 @@ repos: 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: diff --git a/Makefile b/Makefile index 06a4cbfd45..a528e048a3 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 \ diff --git a/pyproject.toml b/pyproject.toml index 1d6ee00905..c6b11fac8c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,12 +34,11 @@ dynamic = ["version"] dev = [ "build", "chardet", - "flake8", - "flake8-pyproject", "pytest", "pytest-cov", "pytest-dependency", "Pygments", + "ruff", "tomli" ] hard-encoding-detection = [ @@ -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] @@ -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