From 8069bbc020038ea2a4aacf4c1ae7444279bb0459 Mon Sep 17 00:00:00 2001 From: Jakob van Santen Date: Tue, 28 May 2024 11:07:26 +0200 Subject: [PATCH 1/4] Run mypy on tests --- .github/workflows/ci.yml | 7 +++++++ .github/workflows/main.yml | 1 + 2 files changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 979e134d..f2683926 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,11 @@ on: type: string # renovate: datasource=pypi depName=ruff versioning=pep440 default: "0.4.5" + mypy-check-files: + required: false + description: extra files to check with mypy + type: string + default: "" secrets: PYPI_API_TOKEN: required: true @@ -94,6 +99,8 @@ jobs: - name: Install root run: poetry run pip install -e . --no-deps - run: poetry run mypy + - if: ${{ inputs.mypy-check-files }} + run: poetry run mypy ${{ inputs.mypy-check-files }} check_version: name: Tag version bump diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fd805e00..d820073a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,3 +19,4 @@ jobs: secrets: inherit with: lint: true + mypy-check-files: tests From e5829cde924440746e32db05349563534b5709d2 Mon Sep 17 00:00:00 2001 From: Jakob van Santen Date: Tue, 28 May 2024 11:10:24 +0200 Subject: [PATCH 2/4] AmpelUnit: harmonize dict() with AmpelBaseModel --- ampel/base/AmpelUnit.py | 1 + tests/test_AmpelVault.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ampel/base/AmpelUnit.py b/ampel/base/AmpelUnit.py index c6b96954..d1c32edd 100644 --- a/ampel/base/AmpelUnit.py +++ b/ampel/base/AmpelUnit.py @@ -233,6 +233,7 @@ def dict( exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, + warnings: bool = True, ) -> dict[str, Any]: if hasattr(self, "__slots__"): diff --git a/tests/test_AmpelVault.py b/tests/test_AmpelVault.py index 75beaf1a..9d294458 100644 --- a/tests/test_AmpelVault.py +++ b/tests/test_AmpelVault.py @@ -48,7 +48,7 @@ def test_secret_resolution() -> None: def test_value_set(): - secret = NamedSecret(label="foo") + secret = NamedSecret[int](label="foo") with pytest.raises(ValueError, match="Secret not yet resolved"): secret.get() secret.set(1) From a82622cabab27955556d442cf428ee825a8314a0 Mon Sep 17 00:00:00 2001 From: Jakob van Santen Date: Tue, 28 May 2024 11:21:45 +0200 Subject: [PATCH 3/4] ignore override warning for "backwards" inheritance --- tests/test_AmpelUnit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_AmpelUnit.py b/tests/test_AmpelUnit.py index 5492ee0c..04d01d08 100644 --- a/tests/test_AmpelUnit.py +++ b/tests/test_AmpelUnit.py @@ -29,7 +29,8 @@ def __init__(self, **kwargs): class Derived1(PrivateMixin, U, M): ... - class Derived2(PrivateMixin, M, U): ... + # ignore: Definition of "dict" in base class "BaseModel" is incompatible with definition in base class "AmpelUnit" + class Derived2(PrivateMixin, M, U): ... # type: ignore[misc] kwargs = {"unit_param": 1, "basemodel_param": 2} defaults = {"unit_param_with_default": 3, "basemodel_param_with_default": 2} From ca482f72cd4e5a96faebb7dcea3e748c0e9708c2 Mon Sep 17 00:00:00 2001 From: Jakob van Santen Date: Tue, 28 May 2024 11:24:16 +0200 Subject: [PATCH 4/4] Bump version to 0.10.1.post0 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fadfbe41..fc5c7740 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ampel-interface" -version = "0.10.1" +version = "0.10.1.post0" description = "Base classes for the Ampel analysis platform" authors = ["Valery Brinnel"] maintainers = ["Jakob van Santen "]