From deb7631a3a9e6cf611e4c1ae624e08f5ada355d3 Mon Sep 17 00:00:00 2001 From: Arthur Meyre Date: Mon, 26 Jul 2021 18:00:39 +0200 Subject: [PATCH] chore(tools): add mypy_test and mypy_ci target - update tests that were failing with new mypy check - mypy_test runs mypy on all .py source files in tests - mypy_ci runs mypy and mypy_test, mypy is for source i.e. hdk/ only --- Makefile | 9 ++++++++- tests/common/data_types/test_dtypes_helpers.py | 6 +++--- tests/helpers/test_conftest.py | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 033e1b5d0..041b36c33 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ pylint: conformance: python_format .PHONY: conformance -pcc: check_python_format pylint mypy +pcc: check_python_format pylint mypy_ci .PHONY: pcc pytest: @@ -41,6 +41,13 @@ mypy_ns: poetry run mypy -p hdk .PHONY: mypy_ns +mypy_test: + find ./tests/ -name "*.py" | xargs poetry run mypy --ignore-missing-imports +.PHONY: mypy_test + +mypy_ci: mypy mypy_test +.PHONY: mypy_ci + docs: cd docs && poetry run make html .PHONY: docs diff --git a/tests/common/data_types/test_dtypes_helpers.py b/tests/common/data_types/test_dtypes_helpers.py index 43b5fd872..683f04dd2 100644 --- a/tests/common/data_types/test_dtypes_helpers.py +++ b/tests/common/data_types/test_dtypes_helpers.py @@ -7,7 +7,7 @@ from hdk.common.data_types.dtypes_helpers import ( value_is_encrypted_unsigned_integer, ) from hdk.common.data_types.integers import Integer -from hdk.common.data_types.values import ClearValue, EncryptedValue +from hdk.common.data_types.values import BaseValue, ClearValue, EncryptedValue @pytest.mark.parametrize( @@ -25,7 +25,7 @@ from hdk.common.data_types.values import ClearValue, EncryptedValue ), ], ) -def test_value_is_encrypted_integer(value: Integer, expected_result: bool): +def test_value_is_encrypted_integer(value: BaseValue, expected_result: bool): """Test value_is_encrypted_integer helper""" assert value_is_encrypted_integer(value) == expected_result @@ -50,6 +50,6 @@ def test_value_is_encrypted_integer(value: Integer, expected_result: bool): ), ], ) -def test_value_is_encrypted_unsigned_integer(value: Integer, expected_result: bool): +def test_value_is_encrypted_unsigned_integer(value: BaseValue, expected_result: bool): """Test value_is_encrypted_unsigned_integer helper""" assert value_is_encrypted_unsigned_integer(value) == expected_result diff --git a/tests/helpers/test_conftest.py b/tests/helpers/test_conftest.py index 9ed6185af..50b8f7d53 100644 --- a/tests/helpers/test_conftest.py +++ b/tests/helpers/test_conftest.py @@ -17,7 +17,7 @@ def test_digraphs_are_equivalent(test_helpers): return self.computation.__hash__() def __eq__(self, other: object) -> bool: - return self.computation == other.computation + return isinstance(other, self.__class__) and self.computation == other.computation is_equivalent_to = __eq__