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
This commit is contained in:
Arthur Meyre
2021-07-26 18:00:39 +02:00
parent b883995911
commit deb7631a3a
3 changed files with 12 additions and 5 deletions

View File

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

View File

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

View File

@@ -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__