From 9b0ddc68f155284a0bfe50ea8abd208e6c3a50d2 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 21 Aug 2024 21:24:28 +0100 Subject: [PATCH 1/3] Use typeguard to check pytest fixture/parametrization types --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index dda47e24e..107de488f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -97,6 +97,7 @@ optional-dependencies.dev = [ "vws-python==2024.2.19", "vws-test-fixtures==2023.3.5", "vws-web-tools==2023.12.26", + "typeguard==4.3.0", ] urls.Documentation = "https://vws-python-mock.readthedocs.io" urls.Source = "https://github.com/VWS-Python/vws-python-mock" @@ -322,6 +323,9 @@ keep_full_version = true xfail_strict = true log_cli = true +typeguard-packages = """ +tests +""" addopts = [ "--strict-markers", ] From c7d2525c89e21ca717c428403d0bf8b13a12ce83 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 21 Aug 2024 21:32:18 +0100 Subject: [PATCH 2/3] Fix type hints for Python tests --- tests/mock_vws/test_add_target.py | 6 +++--- tests/mock_vws/test_update_target.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/mock_vws/test_add_target.py b/tests/mock_vws/test_add_target.py index 3f549f013..52210a152 100644 --- a/tests/mock_vws/test_add_target.py +++ b/tests/mock_vws/test_add_target.py @@ -378,7 +378,7 @@ def test_name_valid( ], ) def test_name_invalid( - name: str, + name: str | int | None, image_file_failed_state: io.BytesIO, status_code: int, vws_client: VWS, @@ -392,7 +392,7 @@ def test_name_invalid( expected_exception=OopsAnErrorOccurredPossiblyBadName, ) as oops_exc: vws_client.add_target( - name=name, + name=name, # type: ignore[arg-type] width=1, image=image_file_failed_state, application_metadata=None, @@ -404,7 +404,7 @@ def test_name_invalid( with pytest.raises(expected_exception=Fail) as exc: vws_client.add_target( - name=name, + name=name, # type: ignore[arg-type] width=1, image=image_file_failed_state, application_metadata=None, diff --git a/tests/mock_vws/test_update_target.py b/tests/mock_vws/test_update_target.py index 2b7b3faf2..4fd4000fa 100644 --- a/tests/mock_vws/test_update_target.py +++ b/tests/mock_vws/test_update_target.py @@ -545,7 +545,7 @@ def test_name_valid( ], ) def test_name_invalid( - name: str, + name: str | int | None, target_id: str, vuforia_database: VuforiaDatabase, vws_client: VWS, From 59a6e4367439666ef8407f7e37fdae7007f4f1b5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Wed, 21 Aug 2024 20:35:10 +0000 Subject: [PATCH 3/3] [pre-commit.ci lite] apply automatic fixes --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 107de488f..833bfe25b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -88,6 +88,7 @@ optional-dependencies.dev = [ "sphinxcontrib-spelling==8", "sybil==6.1.1", "tenacity==9.0.0", + "typeguard==4.3.0", "types-docker==7.1.0.20240821", "types-pillow==10.2.0.20240520", "types-pyyaml==6.0.12.20240808", @@ -97,7 +98,6 @@ optional-dependencies.dev = [ "vws-python==2024.2.19", "vws-test-fixtures==2023.3.5", "vws-web-tools==2023.12.26", - "typeguard==4.3.0", ] urls.Documentation = "https://vws-python-mock.readthedocs.io" urls.Source = "https://github.com/VWS-Python/vws-python-mock"