From 9b5efc2997521c8c6b4887188ddd9cb1b077cf79 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 9 Dec 2023 16:23:18 +0200 Subject: [PATCH 1/3] Dry run CLI in own tox env --- .github/workflows/test.yml | 4 ++++ tox.ini | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3e00cea..13d0c6d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,6 +34,10 @@ jobs: run: | tox -e py + - name: Test CLI + run: | + tox -e cli + - name: Cog if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest' run: | diff --git a/tox.ini b/tox.ini index c08988e..ba88240 100644 --- a/tox.ini +++ b/tox.ini @@ -2,6 +2,7 @@ requires = tox>=4.2 env_list = + cli cog lint py{py3, 313, 312, 311, 310, 39, 38} @@ -17,8 +18,15 @@ commands = --cov-report term \ --cov-report xml \ {posargs} + +[testenv:cli] +commands = pep --version pep --help + pep --dry-run 8 + pep --dry-run 3.13 + pep --dry-run dead batteries + pep next [testenv:cog] deps = From 83aadead6a00e0f9a518fc427869bca8e03a35f6 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 9 Dec 2023 16:24:05 +0200 Subject: [PATCH 2/3] Update config --- .coveragerc | 5 +---- .github/workflows/lint.yml | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.coveragerc b/.coveragerc index ff82131..9075f2f 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/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8509763..dae63b0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: "3.x" - uses: pre-commit/action@v3.0.0 From 2bb027cf559ce281f6eea673834d691646db972c Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 9 Dec 2023 16:32:53 +0200 Subject: [PATCH 3/3] Replace Flake8 with Ruff --- .flake8 | 2 -- .pre-commit-config.yaml | 34 ++++++++-------------------------- pyproject.toml | 27 +++++++++++++++++++++++++-- src/pepotron/__init__.py | 4 ++-- 4 files changed, 35 insertions(+), 32 deletions(-) delete mode 100644 .flake8 diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 2bcd70e..0000000 --- a/.flake8 +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -max-line-length = 88 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 97e42b2..55c1096 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,33 +1,15 @@ repos: - - repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.7 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.10.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, flake8-logging] - - - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.10.0 - hooks: - - id: python-check-blanket-noqa - - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: @@ -41,7 +23,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.6.1 + rev: v1.7.1 hooks: - id: mypy args: [--strict, --pretty, --show-error-codes] @@ -56,7 +38,7 @@ repos: ] - repo: https://github.com/tox-dev/pyproject-fmt - rev: 1.4.1 + rev: 1.5.3 hooks: - id: pyproject-fmt additional_dependencies: [tox] @@ -72,7 +54,7 @@ repos: - id: tox-ini-fmt - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.3 + rev: v4.0.0-alpha.3-1 hooks: - id: prettier args: [--prose-wrap=always, --print-width=88] diff --git a/pyproject.toml b/pyproject.toml index f11aedd..5ac240e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,8 +63,31 @@ version.source = "vcs" [tool.hatch.version.raw-options] local_scheme = "no-local-version" -[tool.isort] -profile = "black" +[tool.ruff] +select = [ + "C4", # flake8-comprehensions + "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 = ["pepotron"] +required-imports = ["from __future__ import annotations"] [tool.pytest.ini_options] addopts = "--color=yes" diff --git a/src/pepotron/__init__.py b/src/pepotron/__init__.py index 222809b..0034c42 100644 --- a/src/pepotron/__init__.py +++ b/src/pepotron/__init__.py @@ -93,7 +93,7 @@ def _next_available_pep() -> int: from itertools import pairwise except ImportError: # Python 3.9 and below - def pairwise(iterable): # type: ignore + def pairwise(iterable): # type: ignore[no-redef,no-untyped-def] from itertools import tee a, b = tee(iterable) @@ -118,7 +118,7 @@ def pairwise(iterable): # type: ignore def _get_github_prs() -> list[Any]: - from ghapi.all import GhApi # type: ignore + from ghapi.all import GhApi # type: ignore[import-not-found] api = GhApi(owner="python", repo="peps", authenticate=False) return api.pulls.list(per_page=100) # type: ignore[no-any-return]