From cd721327d0066883cd20f10765081f99926c3d86 Mon Sep 17 00:00:00 2001 From: Benjamin Bossan Date: Wed, 4 Jun 2025 15:39:50 +0200 Subject: [PATCH 1/2] Add CI workflow --- .github/workflows/ci.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e6ef9e4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,28 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + +jobs: + lint-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.12' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-dev.txt + - name: Run black + run: black --check . + - name: Run ruff + run: ruff check . + - name: Run mypy + run: mypy --strict src.py + - name: Run tests + run: pytest --cov --cov-report=term-missing test.py From 3877fe510200a6a4e06bdb675d731c1a1dedb9a6 Mon Sep 17 00:00:00 2001 From: Benjamin Bossan Date: Wed, 4 Jun 2025 15:45:58 +0200 Subject: [PATCH 2/2] Fix mypy error and cleanup --- src.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src.py b/src.py index ba02748..3b3da03 100644 --- a/src.py +++ b/src.py @@ -13,10 +13,20 @@ import sys import warnings from contextlib import contextmanager -from functools import update_wrapper, wraps +from functools import update_wrapper from importlib.metadata import PackageNotFoundError from importlib.metadata import version as _get_version -from typing import Any, Callable, Dict, Generator, Optional, SupportsInt, Tuple, Union +from typing import ( + Any, + Callable, + Dict, + Generator, + Optional, + SupportsInt, + Tuple, + Union, + cast, +) __all__ = ["versiondispatch"] @@ -198,7 +208,7 @@ def __init__(self, func: AnyFunc) -> None: # this looks kinda strange but makes it so that the docstring of the # original function is conserved - self = wraps(self._impl)(self) + update_wrapper(cast(Callable[..., Any], self), self._impl) def _matches_all_versions( self, package_versions: list[tuple[str, str, BinOp]]