diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml deleted file mode 100644 index d5e1e50..0000000 --- a/.github/workflows/mypy.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Mypy -on: [push, pull_request] -jobs: - build: - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.11' - cache: pip - cache-dependency-path: pyproject.toml - - run: pip install .[types] - - run: mypy --strict --show-error-codes yapw diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 15a1ad8..e7a1155 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,3 +6,14 @@ repos: hooks: - id: ruff - id: ruff-format + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.12.0 + hooks: + - id: mypy + # "In Python 3.11 and newer, the class syntax supports generic named tuple classes." + # https://typing.readthedocs.io/en/latest/spec/namedtuples.html + language_version: "3.11" + exclude: "(docs|tests)/" + additional_dependencies: + - types-orjson + - types-pika diff --git a/pyproject.toml b/pyproject.toml index ca265ec..9bc7840 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,4 +67,9 @@ ignore-variadic-names = true "ARG001", "D", "FBT003", "INP001", "PLR2004", "S", "TRY003", ] "tests/fixtures/*" = ["T201"] # print -"yapw/clients.py" = ["ARG002"] # pika \ No newline at end of file +"yapw/clients.py" = ["ARG002"] # pika + +[tool.mypy] +strict = true +warn_unreachable = true +exclude = "(build|docs|tests)/" diff --git a/yapw/types.py b/yapw/types.py index aeed19c..7b000aa 100644 --- a/yapw/types.py +++ b/yapw/types.py @@ -31,7 +31,7 @@ class State(NamedTuple, Generic[T]): else: - class State(NamedTuple): + class State(NamedTuple): # "TypeError: Multiple inheritance with NamedTuple is not supported" """Attributes that can be used safely in consumer callbacks.""" #: A function to format the routing key.