@@ -59,11 +59,10 @@ class User:
59
59
import dataclasses
60
60
import datetime
61
61
import decimal
62
+ import enum
62
63
import inspect
63
64
import typing as t
64
- import typing
65
65
import uuid
66
- import enum
67
66
68
67
import attr
69
68
import marshmallow
@@ -106,7 +105,7 @@ def class_schema(
106
105
fields = attr .fields (clazz )
107
106
elif issubclass (clazz , (list , dict )):
108
107
raise desert .exceptions .UnknownType (
109
- "Use parametrized generics like typing .List[int] or typing .Dict[str, int] "
108
+ "Use parametrized generics like t .List[int] or t .Dict[str, int] "
110
109
f"instead of list and dict. Got { clazz } ."
111
110
)
112
111
else :
@@ -116,7 +115,7 @@ def class_schema(
116
115
attributes = {k : v for k , v in inspect .getmembers (clazz ) if not k .startswith ("_" )}
117
116
# Update the schema members to contain marshmallow fields instead of dataclass fields
118
117
119
- hints = typing .get_type_hints (clazz )
118
+ hints = t .get_type_hints (clazz )
120
119
for field in fields :
121
120
if field .init :
122
121
attributes [field .name ] = field_for_schema (
@@ -182,7 +181,7 @@ def field_for_schema(
182
181
>>> field_for_schema(enum.Enum("X", "a b c")).__class__
183
182
<class 'marshmallow_enum.EnumField'>
184
183
>>> import typing
185
- >>> field_for_schema(typing .Union[int,str]).__class__
184
+ >>> field_for_schema(t .Union[int,str]).__class__
186
185
<class 'marshmallow_union.Union'>
187
186
>>> field_for_schema(t.NewType('UserId', int)).__class__
188
187
<class 'marshmallow.fields.Integer'>
@@ -267,7 +266,7 @@ def field_for_schema(
267
266
268
267
field = marshmallow_union .Union (subfields )
269
268
270
- # typing .NewType returns a function with a __supertype__ attribute
269
+ # t .NewType returns a function with a __supertype__ attribute
271
270
newtype_supertype = getattr (typ , "__supertype__" , None )
272
271
if newtype_supertype and inspect .isfunction (typ ):
273
272
metadata .setdefault ("description" , typ .__name__ )
0 commit comments