Skip to content

Commit 53017a2

Browse files
committed
Fix mypy type errors in tests
1 parent ad571a5 commit 53017a2

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

pyproject.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ include = [
101101
"serde/toml.py",
102102
"serde/yaml.py",
103103
"serde/pickle.py",
104+
"tests/common.py",
105+
"tests/imported.py",
104106
"tests/test_custom.py",
105107
"tests/test_kwonly.py",
106108
"tests/test_flatten.py",
@@ -111,8 +113,6 @@ include = [
111113
exclude = [
112114
"serde/numpy.py",
113115
"bench",
114-
"tests/common.py",
115-
"tests/imported.py",
116116
"tests/test_basics.py",
117117
"tests/test_compat.py",
118118
"tests/test_core.py",
@@ -135,8 +135,6 @@ exclude = [
135135
"examples/alias.py",
136136
"examples/field_order.py",
137137
"bench",
138-
"tests/common.py",
139-
"tests/imported.py",
140138
"tests/test_basics.py",
141139
"tests/test_compat.py",
142140
"tests/test_core.py",

tests/common.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def yaml_not_supported(se: Any, de: Any, opt: Any) -> bool:
180180
[param([1, 2], list[int]), param({"a": 1}, dict[str, int]), param((1, 1), tuple[int, int])]
181181
)
182182

183-
types_combinations: List = [
183+
types_combinations: List[Any] = [
184184
list(more_itertools.flatten(c)) for c in itertools.combinations(types, 2)
185185
]
186186

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

193193

194-
def make_id_from_dict(d: Dict[str, str]) -> str:
194+
def make_id_from_dict(d: Dict[str, Union[bool, str]]) -> str:
195195
if not d:
196196
return "none"
197197
else:
198198
key = list(d)[0]
199199
return f"{key}-{d[key]}"
200200

201201

202-
def opt_case_ids():
202+
def opt_case_ids() -> List[str]:
203+
"""
204+
Create parametrize test id
205+
"""
203206
return list(map(make_id_from_dict, opt_case))
204207

205208

206-
def type_ids():
209+
def type_ids() -> List[str]:
210+
"""
211+
Create parametrize test id
212+
"""
207213
from serde.compat import typename
208214

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

213219
return list(map(make_id, types))
214220

215221

216-
def type_combinations_ids():
222+
def type_combinations_ids() -> List[str]:
223+
"""
224+
Create parametrize test id
225+
"""
217226
from serde.compat import typename
218227

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

tests/test_de.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from serde.de import from_obj
66

77

8-
def test_from_obj():
8+
def test_from_obj() -> None:
99
# Primitive
1010
assert 10 == from_obj(int, 10, False, False)
1111

0 commit comments

Comments
 (0)