Skip to content

Commit f34774e

Browse files
author
Diego Argueta
committed
PR feedback, lint stuff
1 parent 3ab1151 commit f34774e

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

src/desert/_make.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class User:
5454
Schema: t.ClassVar[Type[Schema]] = Schema # For the type checker
5555
"""
5656

57-
import collections.abc as coll_abc
57+
import collections.abc
5858
import dataclasses
5959
import datetime
6060
import decimal
@@ -245,7 +245,14 @@ def field_for_schema(
245245
if origin:
246246
arguments = typing_inspect.get_args(typ, True)
247247

248-
if origin in (list, t.List, coll_abc.Sequence, coll_abc.MutableSequence):
248+
if origin in (
249+
list,
250+
t.List,
251+
t.Sequence,
252+
t.MutableSequence,
253+
collections.abc.Sequence,
254+
collections.abc.MutableSequence,
255+
):
249256
field = marshmallow.fields.List(field_for_schema(arguments[0]))
250257

251258
if origin in (tuple, t.Tuple) and Ellipsis not in arguments:
@@ -257,7 +264,14 @@ def field_for_schema(
257264
field = VariadicTuple(
258265
field_for_schema(only(arg for arg in arguments if arg != Ellipsis))
259266
)
260-
elif origin in (dict, t.Dict, coll_abc.Mapping, coll_abc.MutableMapping):
267+
elif origin in (
268+
dict,
269+
t.Dict,
270+
t.Mapping,
271+
t.MutableMapping,
272+
collections.abc.Mapping,
273+
collections.abc.MutableMapping,
274+
):
261275
field = marshmallow.fields.Dict(
262276
keys=field_for_schema(arguments[0]),
263277
values=field_for_schema(arguments[1]),

tests/test_make.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,24 +166,24 @@ class A:
166166
@pytest.mark.parametrize("annotation_class", (t.List, t.Sequence, t.MutableSequence))
167167
def test_list(module: DataclassModule, annotation_class: type) -> None:
168168
"""Build a generic list *without* setting a factory on the dataclass."""
169-
klass = type("A", (object,), {"__annotations__": {"y": annotation_class[int]}})
170-
A = module.dataclass(klass)
169+
cls = type("A", (object,), {"__annotations__": {"y": annotation_class[int]}})
170+
A = module.dataclass(cls)
171171

172172
schema = desert.schema_class(A)()
173173
data = schema.load({"y": [1]})
174-
assert data == A([1]) # type: ignore[call-arg]
174+
assert data == A([1])
175175

176176

177177
@pytest.mark.parametrize("annotation_class", (t.Dict, t.Mapping, t.MutableMapping))
178178
def test_dict(module: DataclassModule, annotation_class: type) -> None:
179179
"""Build a dict without setting a factory on the dataclass."""
180-
klass = type("A", (object,), {"__annotations__": {"y": annotation_class[int, int]}})
181-
A = module.dataclass(klass)
180+
cls = type("A", (object,), {"__annotations__": {"y": annotation_class[int, int]}})
181+
A = module.dataclass(cls)
182182

183183
schema = desert.schema_class(A)()
184184
data = schema.load({"y": {1: 2, 3: 4}})
185185

186-
assert data == A({1: 2, 3: 4}) # type: ignore[call-arg]
186+
assert data == A({1: 2, 3: 4})
187187

188188

189189
def test_nested(module: DataclassModule) -> None:

0 commit comments

Comments
 (0)