From 9ee2b2043316c9e70f7dea5fd8120df27c7f0c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= Date: Mon, 6 Apr 2026 18:16:56 -0600 Subject: [PATCH] ci: Check types in CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Edgar Ramírez Mondragón --- .github/workflows/test.yml | 28 +- .pre-commit-config.yaml | 11 +- README.md | 2 - cz_version_bump/__init__.py | 40 ++- cz_version_bump/git.py | 2 +- pyproject.toml | 9 + uv.lock | 670 ++++++++++++++++++++++++------------ 7 files changed, 519 insertions(+), 243 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c2a6177..964548b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,21 +28,33 @@ jobs: - "3.15" steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 - id: setup-python - with: - python-version: ${{ matrix.python-version }} - allow-prereleases: true - name: Install uv uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0 with: + python-version: ${{ matrix.python-version }} version: ">=0.9.0" - name: Install dependencies - env: - UV_PYTHON: ${{ steps.setup-python.outputs.python-path }} run: | uv sync - - name: Run tests run: | uv run pytest + + types: + name: Static Analysis + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - name: Install uv + uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0 + with: + version: ">=0.9.0" + - name: Install dependencies + run: | + uv sync + - name: Check types with mypy + run: | + uv run mypy cz_version_bump tests + - name: Check types with ty + run: | + uv run ty check diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 32d2192..657128b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,8 +15,13 @@ repos: - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.1 + rev: v0.15.9 hooks: - - id: ruff - args: [ --fix ] + - id: ruff-check + args: [ --fix, --show-fixes ] - id: ruff-format + +- repo: https://github.com/hukkin/mdformat + rev: 1.0.0 + hooks: + - id: mdformat diff --git a/README.md b/README.md index 22c6c81..4afd0cd 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,12 @@ Commitizen customized for Meltano projects (https://commitizen-tools.github.io/commitizen/customization) - ## Usage: Install this Python package, and set the Commitizen config option `name` to `cz_version_bump`. If using [`commitizen-action`](https://github.com/commitizen-tools/commitizen-action), this package can be installed using the `extra_requirements` option: - ```yml - name: Version bump uses: commitizen-tools/commitizen-action@master diff --git a/cz_version_bump/__init__.py b/cz_version_bump/__init__.py index a91199b..7476a62 100644 --- a/cz_version_bump/__init__.py +++ b/cz_version_bump/__init__.py @@ -5,7 +5,7 @@ import sys from collections import OrderedDict from textwrap import dedent -from typing import TYPE_CHECKING, Any, ClassVar +from typing import TYPE_CHECKING, Any, ClassVar # noqa: F401 from commitizen import defaults, git from commitizen.cz.base import BaseCommitizen @@ -20,14 +20,16 @@ from typing_extensions import override if TYPE_CHECKING: - from commitizen.defaults import Questions + from collections.abc import Mapping + + from commitizen.question import CzQuestion issue_id_pattern = re.compile(r"\s+\(#(\d+)\)$") class MeltanoCommitizen(BaseCommitizen): bump_pattern = r"^(feat|fix|refactor|perf|break|docs|ci|chore|style|revert|test|build|packaging)(\(.+\))?(!)?" # noqa: E501 - bump_map: ClassVar = OrderedDict( + bump_map = OrderedDict( # noqa: RUF012 ( ( r"^break", @@ -48,16 +50,6 @@ class MeltanoCommitizen(BaseCommitizen): ) ) commit_parser = r"^(?Pfeat|fix|refactor|perf|break|docs|packaging)(?:\((?P[^()\r\n]*)\)|\()?(?P!)?:\s(?P.*)?" # noqa: E501 - schema_pattern = r"(feat|fix|refactor|perf|break|docs|ci|chore|style|revert|test|build|packaging)(?:\((?P[^()\r\n]*)\)|\()?(?P!)?:(\s.*)" # noqa: E501 - schema = dedent( - """ - (): - - - - (BREAKING CHANGE: )