From f4feab56836a1f92f3b418b5f5c5e996275f2988 Mon Sep 17 00:00:00 2001 From: Preocts Date: Fri, 27 Dec 2024 20:58:13 -0500 Subject: [PATCH 1/5] Update pre-commit-config Version update (autoupdate) Remove hooks `debug-statements` and `mixed-line-endings` as rarely used. --- .pre-commit-config.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b8a3336..1be4fc5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ ci: repos: # Batch of helpful formatters and patterns - repo: https://github.com/pre-commit/pre-commit-hooks - rev: "v4.6.0" + rev: "v5.0.0" hooks: - id: check-json - id: check-toml @@ -12,8 +12,6 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - id: check-docstring-first - - id: debug-statements - - id: mixed-line-ending # Adds a standard feel to import segments - repo: https://github.com/pycqa/isort @@ -29,7 +27,7 @@ repos: # Format code. No, I don't like everything black does either. - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.4.2 + rev: 24.10.0 hooks: - id: black @@ -45,6 +43,6 @@ repos: # Type enforcement for Python - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.1 + rev: v1.14.0 hooks: - id: mypy From 6a52cff6c65354d4f4a9b306df18d3e56aa96356 Mon Sep 17 00:00:00 2001 From: Preocts Date: Fri, 27 Dec 2024 21:15:18 -0500 Subject: [PATCH 2/5] Remove development requirements Both `black` and `flake8` are enforced by pre-commit in the CI and are not requirements for developing. `mypy` remains here for support of editor setups that have extensions to use mypy while working but require the library to be installed. --- requirements/requirements-dev.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/requirements/requirements-dev.txt b/requirements/requirements-dev.txt index a764745..c109579 100644 --- a/requirements/requirements-dev.txt +++ b/requirements/requirements-dev.txt @@ -1,9 +1,4 @@ # Development Requirements - linting, formatting, etc. pre-commit -black mypy -flake8 -flake8-builtins -flake8-pep585 -pep8-naming From fdce9982203380de81efd900a999a20c8c5a9993 Mon Sep 17 00:00:00 2001 From: Preocts Date: Fri, 27 Dec 2024 21:22:38 -0500 Subject: [PATCH 3/5] Use venv to ensure pip is updated Use the venv `--update-deps` flag to ensure pip is updated when a new venv is created. --- noxfile.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/noxfile.py b/noxfile.py index a64f157..f9088a7 100644 --- a/noxfile.py +++ b/noxfile.py @@ -107,13 +107,12 @@ def install(session: nox.Session) -> None: activate_command = f"source {venv_path}/activate" if not os.path.exists(VENV_PATH): - session.run(py_command, "-m", "venv", VENV_PATH) - session.run(f"{venv_path}/python", "-m", "pip", "install", "--upgrade", "pip") + session.run(py_command, "-m", "venv", VENV_PATH, "--upgrade-deps") session.run(f"{venv_path}/python", "-m", "pip", "install", "-e", ".[dev,test]") session.run(f"{venv_path}/pre-commit", "install") - if not os.environ.get("VIRTUAL_ENV"): + if not venv_path: session.log(f"\n\nRun '{activate_command}' to enter the virtual environment.\n") From e36f3bf4db87025f9f554d9b5fd8251216c532c3 Mon Sep 17 00:00:00 2001 From: Preocts Date: Fri, 27 Dec 2024 21:27:54 -0500 Subject: [PATCH 4/5] Update black configuration Allow line lengths of 100 for black and remove flake8's config on length. flake8 is already configured to ignore line length violations. Reasoning of 100: A line length of 88 is the default which is 8 more than PEP-8 recommendations. This comes from the default recommendation plus two indents worth which amount to a class and method. 100 allows for three more indents. The goal here is not to encourage deeper nesting but to encourage more verbose naming without trying to trim those few characteres. Overall expectation is to keep using a visual guide of 88 characters. --- .flake8 | 1 - pyproject.toml | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.flake8 b/.flake8 index d9b0b18..4d102bd 100644 --- a/.flake8 +++ b/.flake8 @@ -4,4 +4,3 @@ extend-ignore = E501 E203 -max-line-length = 88 diff --git a/pyproject.toml b/pyproject.toml index 284d9dc..2fd37ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,10 @@ homepage = "https://github.com/[ORG NAME]/[REPO NAME]" # [project.scripts] # python-src-example = "module_name.sample:main" +[tool.black] +line-length = 100 +target-version = ['py39'] + [tool.setuptools.package-data] "module_name" = ["py.typed"] From 37cf7e52cb6849fcb0251effd2395a6b008b8618 Mon Sep 17 00:00:00 2001 From: Preocts Date: Fri, 27 Dec 2024 21:35:20 -0500 Subject: [PATCH 5/5] Update github action versions Adds the flag `include-hidden-files: true` to the upload artifact action as behavior was changed in 4.4.1. --- .github/workflows/python-tests.yml | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index b0efbd2..20e7924 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -1,9 +1,9 @@ name: "python tests and coverage" # Uses: -# https://github.com/actions/setup-python -# https://github.com/actions/checkout -# https://github.com/actions/download-artifact -# https://github.com/actions/upload-artifact +# https://github.com/actions/setup-python : 0b93645e9fea7318ecaed2b359559ac225c90a2b +# https://github.com/actions/checkout : 11bd71901bbe5b1630ceea73d27597364c9af683 +# https://github.com/actions/download-artifact : fa0a91b85d4f404e444e00e005971372dc801d16 +# https://github.com/actions/upload-artifact : 6f51ac03b9356f520e9adb1b1b7802705f340c2b on: pull_request: @@ -33,10 +33,10 @@ jobs: steps: - name: "Repo checkout" - uses: "actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11" + uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" - name: "Set up Python ${{ matrix.python-version }}" - uses: "actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c" + uses: "actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b" with: python-version: "${{ matrix.python-version }}" allow-prereleases: true @@ -50,11 +50,12 @@ jobs: nox --session tests_with_coverage-${{ matrix.python-version }} - name: "Save coverage artifact" - uses: "actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3" + uses: "actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b" with: name: "coverage-artifact-${{ matrix.os}}-${{ matrix.python-version}}" path: ".coverage.*" retention-days: 1 + include-hidden-files: true coverage-compile: name: "coverage compile" @@ -62,10 +63,10 @@ jobs: runs-on: "ubuntu-latest" steps: - name: "Repo checkout" - uses: "actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11" + uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" - name: "Set up Python" - uses: "actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c" + uses: "actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b" with: python-version: "3.12" @@ -74,7 +75,7 @@ jobs: python -m pip install --upgrade pip nox - name: "Download coverage artifacts" - uses: "actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427" + uses: "actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16" with: pattern: "coverage-artifact-*" merge-multiple: true @@ -91,10 +92,10 @@ jobs: runs-on: "ubuntu-latest" steps: - name: "Repo checkout" - uses: "actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11" + uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" - name: "Set up Python" - uses: "actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c" + uses: "actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b" with: python-version: "3.12"