Skip to content

Commit

Permalink
Merge pull request #497 from yukinarit/fix-mypy-errors
Browse files Browse the repository at this point in the history
Fix mypy type errors in tests
  • Loading branch information
yukinarit committed Mar 10, 2024
2 parents ad571a5 + 53017a2 commit 1ed0000
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ include = [
"serde/toml.py",
"serde/yaml.py",
"serde/pickle.py",
"tests/common.py",
"tests/imported.py",
"tests/test_custom.py",
"tests/test_kwonly.py",
"tests/test_flatten.py",
Expand All @@ -111,8 +113,6 @@ include = [
exclude = [
"serde/numpy.py",
"bench",
"tests/common.py",
"tests/imported.py",
"tests/test_basics.py",
"tests/test_compat.py",
"tests/test_core.py",
Expand All @@ -135,8 +135,6 @@ exclude = [
"examples/alias.py",
"examples/field_order.py",
"bench",
"tests/common.py",
"tests/imported.py",
"tests/test_basics.py",
"tests/test_compat.py",
"tests/test_core.py",
Expand Down
23 changes: 16 additions & 7 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def yaml_not_supported(se: Any, de: Any, opt: Any) -> bool:
[param([1, 2], list[int]), param({"a": 1}, dict[str, int]), param((1, 1), tuple[int, int])]
)

types_combinations: List = [
types_combinations: List[Any] = [
list(more_itertools.flatten(c)) for c in itertools.combinations(types, 2)
]

Expand All @@ -191,32 +191,41 @@ def yaml_not_supported(se: Any, de: Any, opt: Any) -> bool:
]


def make_id_from_dict(d: Dict[str, str]) -> str:
def make_id_from_dict(d: Dict[str, Union[bool, str]]) -> str:
if not d:
return "none"
else:
key = list(d)[0]
return f"{key}-{d[key]}"


def opt_case_ids():
def opt_case_ids() -> List[str]:
"""
Create parametrize test id
"""
return list(map(make_id_from_dict, opt_case))


def type_ids():
def type_ids() -> List[str]:
"""
Create parametrize test id
"""
from serde.compat import typename

def make_id(pair: Tuple):
def make_id(pair: Tuple[Any, ...]) -> str:
t, T, _ = pair
return f"{typename(T)}({t})"

return list(map(make_id, types))


def type_combinations_ids():
def type_combinations_ids() -> List[str]:
"""
Create parametrize test id
"""
from serde.compat import typename

def make_id(quad: Tuple):
def make_id(quad: Tuple[Any, ...]) -> str:
t, T, u, U = quad
return f"{typename(T)}({t})-{typename(U)}({u})"

Expand Down
2 changes: 1 addition & 1 deletion tests/test_de.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from serde.de import from_obj


def test_from_obj():
def test_from_obj() -> None:
# Primitive
assert 10 == from_obj(int, 10, False, False)

Expand Down

0 comments on commit 1ed0000

Please sign in to comment.