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 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]]