From 413a41edc92df6e0a0b6843f33de4dea63e8a2e2 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Thu, 12 Dec 2024 14:41:15 -0500 Subject: [PATCH 01/25] add reusable mypy action --- .github/workflows/reusable-mypy.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/reusable-mypy.yml diff --git a/.github/workflows/reusable-mypy.yml b/.github/workflows/reusable-mypy.yml new file mode 100644 index 0000000..52a0a30 --- /dev/null +++ b/.github/workflows/reusable-mypy.yml @@ -0,0 +1,26 @@ +on: + workflow_call: + inputs: + source_directory: + required: true + type: string + +jobs: + check-with-ruff: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Python + uses: actions/setup-python@v5 + with: + python-version: 3.x + + - name: Install dependencies and type information + run: | + python -m pip install --upgrade pip + python -m pip install mypy + mypy --install-types --non-interactive ${{ inputs.source_directory }} + + - name: mypy static typing check + run: mypy --ignore-missing-imports ${{ inputs.source_directory }} From bd27be50d0553ae8e7f8a55690215b9541e4b98a Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Thu, 12 Dec 2024 14:41:55 -0500 Subject: [PATCH 02/25] words --- .github/workflows/reusable-mypy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-mypy.yml b/.github/workflows/reusable-mypy.yml index 52a0a30..5188c3f 100644 --- a/.github/workflows/reusable-mypy.yml +++ b/.github/workflows/reusable-mypy.yml @@ -6,7 +6,7 @@ on: type: string jobs: - check-with-ruff: + check-with-mypy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -22,5 +22,5 @@ jobs: python -m pip install mypy mypy --install-types --non-interactive ${{ inputs.source_directory }} - - name: mypy static typing check + - name: mypy static type check run: mypy --ignore-missing-imports ${{ inputs.source_directory }} From 2e0983217fc1b44a4aa2dc7a9c8953432e78f3c9 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Thu, 12 Dec 2024 14:55:49 -0500 Subject: [PATCH 03/25] move to one command with necessary options --- .github/workflows/reusable-mypy.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/reusable-mypy.yml b/.github/workflows/reusable-mypy.yml index 5188c3f..57a0c88 100644 --- a/.github/workflows/reusable-mypy.yml +++ b/.github/workflows/reusable-mypy.yml @@ -20,7 +20,6 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install mypy - mypy --install-types --non-interactive ${{ inputs.source_directory }} - name: mypy static type check - run: mypy --ignore-missing-imports ${{ inputs.source_directory }} + run: mypy --install-types --ignore-missing-imports --non-interactive --pretty ${{ inputs.source_directory }} From 18e501785767a43b3b55e5c8dfd99b05ce67fdfa Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Thu, 12 Dec 2024 15:06:41 -0500 Subject: [PATCH 04/25] update changelog for mypy action --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90dea0f..cb26cfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/) and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.13.0] +### Added +- [`reusable-mypy`](.github/workflows/reusable-mypy.yml) reusable workflow for performing static type checking with [mypy](https://github.com/python/mypy). + ## [0.12.1] ### Fixed - The [`reusable-release-action`](.github/workflows/reusable-release.yml) now uses the `gh` CLI instead of the archived `repo-sync/pull-request` action. From d16e2d5d36be4e70cad08c69418b81a4c3e13e93 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Thu, 12 Dec 2024 15:11:05 -0500 Subject: [PATCH 05/25] remove inputs as there may be multiple source dirs --- .github/workflows/reusable-mypy.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/reusable-mypy.yml b/.github/workflows/reusable-mypy.yml index 57a0c88..013f97f 100644 --- a/.github/workflows/reusable-mypy.yml +++ b/.github/workflows/reusable-mypy.yml @@ -1,9 +1,5 @@ on: workflow_call: - inputs: - source_directory: - required: true - type: string jobs: check-with-mypy: @@ -22,4 +18,4 @@ jobs: python -m pip install mypy - name: mypy static type check - run: mypy --install-types --ignore-missing-imports --non-interactive --pretty ${{ inputs.source_directory }} + run: mypy --install-types --ignore-missing-imports --non-interactive --pretty . From dfb09c1eae767bd121ffc2bddc8dbb3597bee3a2 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Fri, 13 Dec 2024 15:14:19 -0500 Subject: [PATCH 06/25] Update .github/workflows/reusable-mypy.yml Co-authored-by: Jake Herrmann --- .github/workflows/reusable-mypy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-mypy.yml b/.github/workflows/reusable-mypy.yml index 013f97f..be9a609 100644 --- a/.github/workflows/reusable-mypy.yml +++ b/.github/workflows/reusable-mypy.yml @@ -18,4 +18,4 @@ jobs: python -m pip install mypy - name: mypy static type check - run: mypy --install-types --ignore-missing-imports --non-interactive --pretty . + run: mkdir .mypy_cache && mypy --install-types --ignore-missing-imports --non-interactive --pretty . From 36430195bbcf393bf6e04a516a9987f41d358fa2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 12:46:57 +0000 Subject: [PATCH 07/25] Bump trufflesecurity/trufflehog from 3.85.0 to 3.86.1 Bumps [trufflesecurity/trufflehog](https://github.com/trufflesecurity/trufflehog) from 3.85.0 to 3.86.1. - [Release notes](https://github.com/trufflesecurity/trufflehog/releases) - [Changelog](https://github.com/trufflesecurity/trufflehog/blob/main/.goreleaser.yml) - [Commits](https://github.com/trufflesecurity/trufflehog/compare/v3.85.0...v3.86.1) --- updated-dependencies: - dependency-name: trufflesecurity/trufflehog dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/reusable-secrets-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-secrets-analysis.yml b/.github/workflows/reusable-secrets-analysis.yml index dd6c657..71fa049 100644 --- a/.github/workflows/reusable-secrets-analysis.yml +++ b/.github/workflows/reusable-secrets-analysis.yml @@ -10,7 +10,7 @@ jobs: fetch-depth: 0 - name: Secret Scanning - uses: trufflesecurity/trufflehog@v3.85.0 + uses: trufflesecurity/trufflehog@v3.86.1 with: base: main extra_args: --only-verified From 05fc34c64d1e943acea98f1a480e148a8ae88ec8 Mon Sep 17 00:00:00 2001 From: tools-bot Date: Tue, 17 Dec 2024 21:24:22 +0000 Subject: [PATCH 08/25] Bump actions example's version to v0.13.2 --- README.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 4b17086..0dd1292 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ jobs: call-bump-version-workflow: # For first-time setup, create a v0.0.0 tag as shown here: # https://github.com/ASFHyP3/actions#reusable-bump-versionyml - uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.13.2 with: user: tools-bot # Optional; default shown email: UAF-asf-apd@alaska.edu # Optional; default shown @@ -68,7 +68,7 @@ on: jobs: call-changelog-check-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-changelog-check.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-changelog-check.yml@v0.13.2 ``` to ensure the changelog has been updated for any PR to `develop` or `main`. @@ -86,7 +86,7 @@ on: jobs: call-create-jira-issue-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-create-jira-issue.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-create-jira-issue.yml@v0.13.2 secrets: JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} @@ -139,13 +139,13 @@ on: jobs: call-version-info-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.13.2 with: conda_env_name: hyp3-plugin call-docker-ecr-workflow: needs: call-version-info-workflow - uses: ASFHyP3/actions/.github/workflows/reusable-docker-ecr.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-docker-ecr.yml@v0.13.2 with: version_tag: ${{ needs.call-version-info-workflow.outputs.version_tag }} ecr_registry: 845172464411.dkr.ecr.us-west-2.amazonaws.com @@ -180,13 +180,13 @@ on: jobs: call-version-info-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.13.2 with: conda_env_name: hyp3-plugin call-docker-ghcr-workflow: needs: call-version-info-workflow - uses: ASFHyP3/actions/.github/workflows/reusable-docker-ghcr.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-docker-ghcr.yml@v0.13.2 with: version_tag: ${{ needs.call-version-info-workflow.outputs.version_tag }} user: ${{ github.actor }} @@ -208,7 +208,7 @@ on: push jobs: call-flake8-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-flake8.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-flake8.yml@v0.13.2 with: local_package_names: hyp3_plugin # Required; comma-seperated list of names that should be considered local to your application excludes: hyp3_plugin/ugly.py # Optional; comma-separated list of glob patterns to exclude from checks @@ -227,7 +227,7 @@ on: push jobs: call-ruff-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-ruff.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-ruff.yml@v0.13.2 ``` Make sure that `pyproject.toml` contains the appropriate Python version specifier @@ -289,7 +289,7 @@ on: jobs: call-git-object-name-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-git-object-name.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-git-object-name.yml@v0.13.2 echo-git-object-name-outputs: needs: call-git-object-name-workflow @@ -319,7 +319,7 @@ on: jobs: call-labeled-pr-check-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.13.2 ``` to ensure a release label is included on any PR to `main`. @@ -343,7 +343,7 @@ on: jobs: call-pytest-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-pytest.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-pytest.yml@v0.13.2 with: local_package_name: hyp3_plugin # Required; package to produce a coverage report for fail_fast: false # Optional; default shown @@ -372,7 +372,7 @@ on: jobs: call-release-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-release.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-release.yml@v0.13.2 with: release_prefix: HyP3-CI release_branch: main # Optional; default shown @@ -401,7 +401,7 @@ on: jobs: call-release-checklist-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-release-checklist-comment.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-release-checklist-comment.yml@v0.13.2 permissions: pull-requests: write with: @@ -431,7 +431,7 @@ on: push jobs: call-secrets-analysis-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-secrets-analysis.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-secrets-analysis.yml@v0.13.2 ``` to scan every push for secrets. @@ -457,7 +457,7 @@ on: jobs: call-version-info-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.13.2 with: python_version: '3.12' # Optional; default shown From 1491d52974a580d90de2ad2d9d8d87a2f6e70f1b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Dec 2024 12:58:21 +0000 Subject: [PATCH 09/25] Bump ASFHyP3/actions from 0.12.0 to 0.13.2 Bumps [ASFHyP3/actions](https://github.com/asfhyp3/actions) from 0.12.0 to 0.13.2. - [Release notes](https://github.com/asfhyp3/actions/releases) - [Changelog](https://github.com/ASFHyP3/actions/blob/develop/CHANGELOG.md) - [Commits](https://github.com/asfhyp3/actions/compare/v0.12.0...v0.13.2) --- updated-dependencies: - dependency-name: ASFHyP3/actions dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/changelog.yml | 2 +- .github/workflows/create-jira-issue.yml | 2 +- .github/workflows/labeled-pr.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- .github/workflows/tag-version.yml | 2 +- .github/workflows/update-examples.yml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index db268b9..600d1ac 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -11,4 +11,4 @@ on: - develop jobs: call-changelog-check-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-changelog-check.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-changelog-check.yml@v0.13.2 diff --git a/.github/workflows/create-jira-issue.yml b/.github/workflows/create-jira-issue.yml index d95ef84..7646baa 100644 --- a/.github/workflows/create-jira-issue.yml +++ b/.github/workflows/create-jira-issue.yml @@ -6,7 +6,7 @@ on: jobs: call-create-jira-issue-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-create-jira-issue.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-create-jira-issue.yml@v0.13.2 secrets: JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} diff --git a/.github/workflows/labeled-pr.yml b/.github/workflows/labeled-pr.yml index f408f3b..465aaa8 100644 --- a/.github/workflows/labeled-pr.yml +++ b/.github/workflows/labeled-pr.yml @@ -12,4 +12,4 @@ on: jobs: call-labeled-pr-check-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.13.2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ad0db05..99b8464 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ on: jobs: call-release-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-release.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-release.yml@v0.13.2 with: release_prefix: Actions secrets: diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 17d0d55..244aab8 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -4,4 +4,4 @@ on: push jobs: call-secrets-analysis-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-secrets-analysis.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-secrets-analysis.yml@v0.13.2 diff --git a/.github/workflows/tag-version.yml b/.github/workflows/tag-version.yml index 117193b..f62a9f4 100644 --- a/.github/workflows/tag-version.yml +++ b/.github/workflows/tag-version.yml @@ -7,6 +7,6 @@ on: jobs: call-bump-version-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.13.2 secrets: USER_TOKEN: ${{ secrets.TOOLS_BOT_PAK }} diff --git a/.github/workflows/update-examples.yml b/.github/workflows/update-examples.yml index f4ebe15..cd2765f 100644 --- a/.github/workflows/update-examples.yml +++ b/.github/workflows/update-examples.yml @@ -13,7 +13,7 @@ on: jobs: call-git-object-name-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-git-object-name.yml@v0.12.0 + uses: ASFHyP3/actions/.github/workflows/reusable-git-object-name.yml@v0.13.2 upate_actions_examples: needs: call-git-object-name-workflow From fdbd5964de8d1539a9543b6ab4359ac5cccfc089 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Mon, 6 Jan 2025 14:05:02 -0500 Subject: [PATCH 10/25] run mypy in environment --- .github/workflows/reusable-mypy.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/reusable-mypy.yml b/.github/workflows/reusable-mypy.yml index be9a609..ead8eaa 100644 --- a/.github/workflows/reusable-mypy.yml +++ b/.github/workflows/reusable-mypy.yml @@ -7,15 +7,12 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install Python - uses: actions/setup-python@v5 + - uses: mamba-org/setup-micromamba@v2 with: - python-version: 3.x + environment-file: environment.yml - - name: Install dependencies and type information + - name: Pytest in conda environment + shell: bash -l {0} run: | - python -m pip install --upgrade pip - python -m pip install mypy - - - name: mypy static type check - run: mkdir .mypy_cache && mypy --install-types --ignore-missing-imports --non-interactive --pretty . + python -m pip install --no-deps . + mkdir .mypy_cache && mypy --install-types --ignore-missing-imports --non-interactive --pretty . From 584967cef75af535029f3b84ba89429353c96a66 Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Mon, 6 Jan 2025 10:18:12 -0900 Subject: [PATCH 11/25] remove flake8, add mypy section to README --- .github/workflows/reusable-flake8.yml | 31 ------------- CHANGELOG.md | 3 ++ README.md | 63 +++++++++++++++++++-------- 3 files changed, 47 insertions(+), 50 deletions(-) delete mode 100644 .github/workflows/reusable-flake8.yml diff --git a/.github/workflows/reusable-flake8.yml b/.github/workflows/reusable-flake8.yml deleted file mode 100644 index 823912a..0000000 --- a/.github/workflows/reusable-flake8.yml +++ /dev/null @@ -1,31 +0,0 @@ -on: - workflow_call: - inputs: - local_package_names: - required: true - type: string - excludes: - required: false - default: '' - type: string - -jobs: - flake8: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 - with: - python-version: 3.x - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install flake8 flake8-import-order flake8-blind-except flake8-builtins - - - name: Lint with flake8 - run: | - [ -z ${{ inputs.excludes }} ] && export EXCLUDES="" || export EXCLUDES="--exclude ${{ inputs.excludes }}" - flake8 --max-line-length=120 --import-order-style=pycharm --statistics \ - --application-import-names ${{ inputs.local_package_names }} ${EXCLUDES} diff --git a/CHANGELOG.md b/CHANGELOG.md index 65a4b24..d28ff58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Added - [`reusable-mypy`](.github/workflows/reusable-mypy.yml) reusable workflow for performing static type checking with [mypy](https://github.com/python/mypy). +### Removed +- `reusable-flake8.yml` has been removed. We recommend [`reusable-ruff`](.github/workflows/reusable-ruff.yml) instead. + ## [0.13.2] ### Fixed diff --git a/README.md b/README.md index 0dd1292..a8fe0e0 100644 --- a/README.md +++ b/README.md @@ -197,25 +197,6 @@ jobs: USER_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` -### [`reusable-flake8.yml`](./.github/workflows/reusable-flake8.yml) - -Runs [flake8](https://flake8.pycqa.org/en/latest/) to enforce ASFHyP3's Python style guide. Use like: - -```yaml -name: Static analysis - -on: push - -jobs: - call-flake8-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-flake8.yml@v0.13.2 - with: - local_package_names: hyp3_plugin # Required; comma-seperated list of names that should be considered local to your application - excludes: hyp3_plugin/ugly.py # Optional; comma-separated list of glob patterns to exclude from checks -``` - -to ensure the Python code is styled correctly. - ### [`reusable-ruff.yml`](./.github/workflows/reusable-ruff.yml) Runs [Ruff](https://docs.astral.sh/ruff/) to enforce a configurable Python style guide. Use like: @@ -269,6 +250,50 @@ case-sensitive = true lines-after-imports = 2 ``` +### [`reusable-mypy.yml`](./.github/workflows/reusable-mypy.yml) + +Runs [mypy](https://mypy-lang.org/) to perform static type checking for Python code. Use like: + +```yaml +name: Static analysis + +on: push + +jobs: + call-mypy-workflow: + uses: ASFHyP3/actions/.github/workflows/reusable-mypy.yml@v0.14.0 +``` + +To use our recommended configuration options, add the following to `pyproject.toml`: + +```toml +[tool.mypy] +python_version = "" +warn_redundant_casts = true +warn_unused_ignores = true +warn_unreachable = true +strict_equality = true +check_untyped_defs = true +``` + +Populate the +[`python_version`](https://mypy.readthedocs.io/en/stable/config_file.html#confval-python_version) field +with the appropriate Python version in the format `MAJOR.MINOR`. +This should probably be the minimum Python version supported by the project, +determined by the value of the +[`requires-python`](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#python-requires) field. +For example, if `requires-python` specifies `>=3.10`, then you may want to set `python_version` to `3.10`, like this: + +```toml +[project] +requires-python = ">=3.10" + +... + +[tool.mypy] +python_version = "3.10" +``` + ### [`reusable-git-object-name.yml`](./.github/workflows/reusable-git-object-name.yml) Outputs the human-readable git object name from [`git describe --dirty --tags --long --match "*[0-9]*"`](https://git-scm.com/docs/git-describe) From c41c5a9fb762a0019d0c648029bc959c1234d4b3 Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Mon, 6 Jan 2025 10:20:50 -0900 Subject: [PATCH 12/25] formatting --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a8fe0e0..625dd4c 100644 --- a/README.md +++ b/README.md @@ -284,7 +284,7 @@ determined by the value of the [`requires-python`](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#python-requires) field. For example, if `requires-python` specifies `>=3.10`, then you may want to set `python_version` to `3.10`, like this: -```toml +``` [project] requires-python = ">=3.10" From ac540a0c89be5e8d770bb4b988da1a13b4233b8f Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Mon, 6 Jan 2025 14:22:01 -0500 Subject: [PATCH 13/25] change name of step --- .github/workflows/reusable-mypy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-mypy.yml b/.github/workflows/reusable-mypy.yml index ead8eaa..18ddffb 100644 --- a/.github/workflows/reusable-mypy.yml +++ b/.github/workflows/reusable-mypy.yml @@ -11,7 +11,7 @@ jobs: with: environment-file: environment.yml - - name: Pytest in conda environment + - name: Check with MyPy shell: bash -l {0} run: | python -m pip install --no-deps . From f1e98bac41252dd5f43d0ff0e7b763760adb00b1 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Mon, 6 Jan 2025 14:25:28 -0500 Subject: [PATCH 14/25] dont install self --- .github/workflows/reusable-mypy.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/reusable-mypy.yml b/.github/workflows/reusable-mypy.yml index 18ddffb..37cd4cd 100644 --- a/.github/workflows/reusable-mypy.yml +++ b/.github/workflows/reusable-mypy.yml @@ -14,5 +14,4 @@ jobs: - name: Check with MyPy shell: bash -l {0} run: | - python -m pip install --no-deps . mkdir .mypy_cache && mypy --install-types --ignore-missing-imports --non-interactive --pretty . From 92f690542d7bf0ff88661880b99ee145baf5d623 Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Mon, 6 Jan 2025 11:08:15 -0900 Subject: [PATCH 15/25] output ruff commands to run on failure --- .github/workflows/reusable-ruff.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/reusable-ruff.yml b/.github/workflows/reusable-ruff.yml index fdf4216..9da7c4c 100644 --- a/.github/workflows/reusable-ruff.yml +++ b/.github/workflows/reusable-ruff.yml @@ -17,10 +17,18 @@ jobs: python -m pip install --upgrade pip python -m pip install ruff - - name: Ruff linting check - # To automatically fix errors, run `ruff check --fix .` + - name: ruff check + id: ruff_check run: ruff check --output-format=github . - - name: Ruff format check - # To automatically fix errors, run `ruff format .` + - name: ruff check failure + if: ${{ failure() && steps.ruff_check.conclusion == 'failure' }} + run: echo 'To automatically fix errors, run `ruff check --fix .`' + + - name: ruff format + id: ruff_format run: ruff format --diff . + + - name: ruff format failure + if: ${{ failure() && steps.ruff_format.conclusion == 'failure' }} + run: echo 'To automatically fix errors, run `ruff format .`' From 2316962d3930d9e0f28fc060bb4710ec14bf804d Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Mon, 6 Jan 2025 11:16:31 -0900 Subject: [PATCH 16/25] exit 1 for ruff check failure step --- .github/workflows/reusable-ruff.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-ruff.yml b/.github/workflows/reusable-ruff.yml index 9da7c4c..589a509 100644 --- a/.github/workflows/reusable-ruff.yml +++ b/.github/workflows/reusable-ruff.yml @@ -23,7 +23,7 @@ jobs: - name: ruff check failure if: ${{ failure() && steps.ruff_check.conclusion == 'failure' }} - run: echo 'To automatically fix errors, run `ruff check --fix .`' + run: echo 'To automatically fix errors, run `ruff check --fix .`' && exit 1 - name: ruff format id: ruff_format From 461347e8aee5d2b16ae21ab9fc2438e79b35298f Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Mon, 6 Jan 2025 11:20:43 -0900 Subject: [PATCH 17/25] revise ruff failure handling --- .github/workflows/reusable-ruff.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/reusable-ruff.yml b/.github/workflows/reusable-ruff.yml index 589a509..9afa2ca 100644 --- a/.github/workflows/reusable-ruff.yml +++ b/.github/workflows/reusable-ruff.yml @@ -19,11 +19,7 @@ jobs: - name: ruff check id: ruff_check - run: ruff check --output-format=github . - - - name: ruff check failure - if: ${{ failure() && steps.ruff_check.conclusion == 'failure' }} - run: echo 'To automatically fix errors, run `ruff check --fix .`' && exit 1 + run: ruff check --output-format=github . || (echo 'To automatically fix errors, run `ruff check --fix .`' && exit 1) - name: ruff format id: ruff_format From 00e40b97d85bceb691b113022c49434165f72ee3 Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Mon, 6 Jan 2025 11:25:46 -0900 Subject: [PATCH 18/25] do not manually print --fix command for ruff check --- .github/workflows/reusable-ruff.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-ruff.yml b/.github/workflows/reusable-ruff.yml index 9afa2ca..bb47a42 100644 --- a/.github/workflows/reusable-ruff.yml +++ b/.github/workflows/reusable-ruff.yml @@ -19,7 +19,7 @@ jobs: - name: ruff check id: ruff_check - run: ruff check --output-format=github . || (echo 'To automatically fix errors, run `ruff check --fix .`' && exit 1) + run: ruff check --output-format=github . - name: ruff format id: ruff_format From 97e0ffac4508b8c1fd0346a6a2b3d2991844f4ae Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Mon, 6 Jan 2025 11:34:28 -0900 Subject: [PATCH 19/25] finalize ruff error handling --- .github/workflows/reusable-ruff.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/reusable-ruff.yml b/.github/workflows/reusable-ruff.yml index bb47a42..913e5a5 100644 --- a/.github/workflows/reusable-ruff.yml +++ b/.github/workflows/reusable-ruff.yml @@ -18,13 +18,7 @@ jobs: python -m pip install ruff - name: ruff check - id: ruff_check - run: ruff check --output-format=github . + run: ruff check --output-format=github - name: ruff format - id: ruff_format - run: ruff format --diff . - - - name: ruff format failure - if: ${{ failure() && steps.ruff_format.conclusion == 'failure' }} - run: echo 'To automatically fix errors, run `ruff format .`' + run: ruff format --diff || (echo 'To automatically re-format, run `ruff format`' && exit 1) From 186acf4fa54c35f3967ca3d2cac730a91e158d20 Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Mon, 6 Jan 2025 11:38:29 -0900 Subject: [PATCH 20/25] ruff check output format --- .github/workflows/reusable-ruff.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-ruff.yml b/.github/workflows/reusable-ruff.yml index 913e5a5..30ae76e 100644 --- a/.github/workflows/reusable-ruff.yml +++ b/.github/workflows/reusable-ruff.yml @@ -18,7 +18,7 @@ jobs: python -m pip install ruff - name: ruff check - run: ruff check --output-format=github + run: ruff check - name: ruff format run: ruff format --diff || (echo 'To automatically re-format, run `ruff format`' && exit 1) From d020a36247ab80ff28de4f7cc34eac8c542c1bb2 Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Mon, 6 Jan 2025 11:43:37 -0900 Subject: [PATCH 21/25] ruff check error message --- .github/workflows/reusable-ruff.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-ruff.yml b/.github/workflows/reusable-ruff.yml index 30ae76e..af8de7e 100644 --- a/.github/workflows/reusable-ruff.yml +++ b/.github/workflows/reusable-ruff.yml @@ -18,7 +18,7 @@ jobs: python -m pip install ruff - name: ruff check - run: ruff check + run: ruff check --output-format=github || (echo 'Run `ruff check` locally to see which errors can be automatically resolved with the `--fix` option.' && exit 1) - name: ruff format run: ruff format --diff || (echo 'To automatically re-format, run `ruff format`' && exit 1) From 44d3c89c79775091fb5df3ff07c89aab6e53e859 Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Mon, 6 Jan 2025 11:46:57 -0900 Subject: [PATCH 22/25] revise message --- .github/workflows/reusable-ruff.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-ruff.yml b/.github/workflows/reusable-ruff.yml index af8de7e..2869bb0 100644 --- a/.github/workflows/reusable-ruff.yml +++ b/.github/workflows/reusable-ruff.yml @@ -18,7 +18,7 @@ jobs: python -m pip install ruff - name: ruff check - run: ruff check --output-format=github || (echo 'Run `ruff check` locally to see which errors can be automatically resolved with the `--fix` option.' && exit 1) + run: ruff check --output-format=github || (echo 'Run `ruff check --fix` to automatically fix errors where possible' && exit 1) - name: ruff format run: ruff format --diff || (echo 'To automatically re-format, run `ruff format`' && exit 1) From 09c66a91a3f00c0e382cb9b7cd8ce6399a5b738e Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Mon, 6 Jan 2025 11:48:38 -0900 Subject: [PATCH 23/25] revise messages --- .github/workflows/reusable-ruff.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-ruff.yml b/.github/workflows/reusable-ruff.yml index 2869bb0..3db0589 100644 --- a/.github/workflows/reusable-ruff.yml +++ b/.github/workflows/reusable-ruff.yml @@ -18,7 +18,7 @@ jobs: python -m pip install ruff - name: ruff check - run: ruff check --output-format=github || (echo 'Run `ruff check --fix` to automatically fix errors where possible' && exit 1) + run: ruff check --output-format=github || (echo 'Run `ruff check --fix` to automatically fix errors where possible.' && exit 1) - name: ruff format - run: ruff format --diff || (echo 'To automatically re-format, run `ruff format`' && exit 1) + run: ruff format --diff || (echo 'Run `ruff format` to automatically re-format.' && exit 1) From a6fd1f47064d8bb20c108a39dec3ac9afb996886 Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Mon, 6 Jan 2025 11:56:26 -0900 Subject: [PATCH 24/25] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d28ff58..683942f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Added - [`reusable-mypy`](.github/workflows/reusable-mypy.yml) reusable workflow for performing static type checking with [mypy](https://github.com/python/mypy). +- [`reusable-ruff`](.github/workflows/reusable-ruff.yml) now prints the commands used to automatically fix errors. ### Removed - `reusable-flake8.yml` has been removed. We recommend [`reusable-ruff`](.github/workflows/reusable-ruff.yml) instead. From 07ec71412c7f8be03e4147ca371d79755e64c26e Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Mon, 6 Jan 2025 11:58:43 -0900 Subject: [PATCH 25/25] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 683942f..fb5e18d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Added - [`reusable-mypy`](.github/workflows/reusable-mypy.yml) reusable workflow for performing static type checking with [mypy](https://github.com/python/mypy). -- [`reusable-ruff`](.github/workflows/reusable-ruff.yml) now prints the commands used to automatically fix errors. +- [`reusable-ruff`](.github/workflows/reusable-ruff.yml) now prints the suggested commands for automatically fixing errors. ### Removed - `reusable-flake8.yml` has been removed. We recommend [`reusable-ruff`](.github/workflows/reusable-ruff.yml) instead.