From 115ced507853c48ea6fe2fb992a58cfeba743a8d Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Wed, 8 Nov 2023 18:00:22 +0200 Subject: [PATCH] Update config --- .coveragerc | 5 +--- .pre-commit-config.yaml | 45 +++++++++++++---------------------- pyproject.toml | 27 +++++++++++++++++++-- tests/data/expected_output.py | 4 ++-- tox.ini | 8 ++++++- 5 files changed, 52 insertions(+), 37 deletions(-) diff --git a/.coveragerc b/.coveragerc index 41f9a3e..396bbf5 100644 --- a/.coveragerc +++ b/.coveragerc @@ -2,10 +2,7 @@ [report] # Regexes for lines to exclude from consideration -exclude_lines = - # Have to re-enable the standard pragma: - pragma: no cover - +exclude_also = # Don't complain if non-runnable code isn't run: if __name__ == .__main__.: def main diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 433802f..d801b2c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,53 +1,37 @@ repos: - - repo: https://github.com/asottile/pyupgrade - rev: v3.14.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.4 hooks: - - id: pyupgrade - args: [--py38-plus] + - id: ruff + args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.9.1 + rev: 23.11.0 hooks: - id: black - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 - hooks: - - id: isort - args: [--add-import=from __future__ import annotations] - - - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 - hooks: - - id: flake8 - additional_dependencies: - [flake8-2020, flake8-errmsg, flake8-implicit-str-concat] - - - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.10.0 - hooks: - - id: python-check-blanket-noqa - - id: python-no-log-warn - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-case-conflict - id: check-merge-conflict - id: check-json - id: check-toml - id: check-yaml - - id: requirements-txt-fixer + - id: debug-statements - id: end-of-file-fixer + - id: requirements-txt-fixer + - id: trailing-whitespace + exclude: tests/data/expected_output.py - repo: https://github.com/tox-dev/pyproject-fmt - rev: 1.2.0 + rev: 1.4.1 hooks: - id: pyproject-fmt additional_dependencies: [tox] - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.14 + rev: v0.15 hooks: - id: validate-pyproject @@ -62,5 +46,10 @@ repos: - id: prettier args: [--prose-wrap=always, --print-width=88] + - repo: meta + hooks: + - id: check-hooks-apply + - id: check-useless-excludes + ci: autoupdate_schedule: quarterly diff --git a/pyproject.toml b/pyproject.toml index a0d71f8..e1eafae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,8 +65,31 @@ version.source = "vcs" [tool.hatch.version.raw-options] local_scheme = "no-local-version" -[tool.isort] -profile = "black" +[tool.ruff] +line-length = 88 +select = [ + "E", # pycodestyle errors + "EM", # flake8-errmsg + "F", # pyflakes errors + "I", # isort + "ISC", # flake8-implicit-str-concat + "PGH", # pygrep-hooks + "RUF100", # unused noqa (yesqa) + "UP", # pyupgrade + "W", # pycodestyle warnings + "YTT", # flake8-2020 + # "LOG", # TODO: enable flake8-logging when it's not in preview anymore +] +extend-ignore = [ + "E203", # Whitespace before ':' + "E221", # Multiple spaces before operator + "E226", # Missing whitespace around arithmetic operator + "E241", # Multiple spaces after ',' +] + +[tool.ruff.isort] +known-first-party = ["norwegianblue"] +required-imports = ["from __future__ import annotations"] [tool.pytest.ini_options] addopts = "--color=yes" diff --git a/tests/data/expected_output.py b/tests/data/expected_output.py index 51913fe..5d59486 100644 --- a/tests/data/expected_output.py +++ b/tests/data/expected_output.py @@ -188,7 +188,7 @@ "18.04 LTS","Bionic Beaver","2018-04-26","18.04.6","2023-04-02","2028-04-01","https://wiki.ubuntu.com/BionicBeaver/ReleaseNotes" "16.04 LTS","Xenial Xerus","2016-04-21","16.04.7","2021-04-02","2026-04-01", "14.04 LTS","Trusty Tahr","2014-04-17","14.04.6","2019-04-02","2024-04-01", -""" # noqa: E501 W291 +""" EXPECTED_TSV = """ "cycle"\t"codename"\t"release"\t"latest"\t"support"\t"eol"\t"link" @@ -201,7 +201,7 @@ "18.04 LTS"\t"Bionic Beaver"\t"2018-04-26"\t"18.04.6"\t"2023-04-02"\t"2028-04-01"\t"https://wiki.ubuntu.com/BionicBeaver/ReleaseNotes" "16.04 LTS"\t"Xenial Xerus"\t"2016-04-21"\t"16.04.7"\t"2021-04-02"\t"2026-04-01"\t "14.04 LTS"\t"Trusty Tahr"\t"2014-04-17"\t"14.04.6"\t"2019-04-02"\t"2024-04-01"\t -""" # noqa: E501 W291 +""" EXPECTED_MD_LOG4J = """ | cycle | release | latest | eol | diff --git a/tox.ini b/tox.ini index 2ec3900..f3d0116 100644 --- a/tox.ini +++ b/tox.ini @@ -11,7 +11,13 @@ env_list = extras = tests commands = - {envpython} -m pytest --cov norwegianblue --cov tests --cov-report html --cov-report term --cov-report xml {posargs} + {envpython} -m pytest \ + --cov norwegianblue \ + --cov tests \ + --cov-report html \ + --cov-report term \ + --cov-report xml \ + {posargs} norwegianblue --version norwegianblue --help eol --version