@@ -59,11 +59,10 @@ class User:
5959import dataclasses
6060import datetime
6161import decimal
62+ import enum
6263import inspect
6364import typing as t
64- import typing
6565import uuid
66- import enum
6766
6867import attr
6968import marshmallow
@@ -106,7 +105,7 @@ def class_schema(
106105 fields = attr .fields (clazz )
107106 elif issubclass (clazz , (list , dict )):
108107 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] "
110109 f"instead of list and dict. Got { clazz } ."
111110 )
112111 else :
@@ -116,7 +115,7 @@ def class_schema(
116115 attributes = {k : v for k , v in inspect .getmembers (clazz ) if not k .startswith ("_" )}
117116 # Update the schema members to contain marshmallow fields instead of dataclass fields
118117
119- hints = typing .get_type_hints (clazz )
118+ hints = t .get_type_hints (clazz )
120119 for field in fields :
121120 if field .init :
122121 attributes [field .name ] = field_for_schema (
@@ -182,7 +181,7 @@ def field_for_schema(
182181 >>> field_for_schema(enum.Enum("X", "a b c")).__class__
183182 <class 'marshmallow_enum.EnumField'>
184183 >>> import typing
185- >>> field_for_schema(typing .Union[int,str]).__class__
184+ >>> field_for_schema(t .Union[int,str]).__class__
186185 <class 'marshmallow_union.Union'>
187186 >>> field_for_schema(t.NewType('UserId', int)).__class__
188187 <class 'marshmallow.fields.Integer'>
@@ -267,7 +266,7 @@ def field_for_schema(
267266
268267 field = marshmallow_union .Union (subfields )
269268
270- # typing .NewType returns a function with a __supertype__ attribute
269+ # t .NewType returns a function with a __supertype__ attribute
271270 newtype_supertype = getattr (typ , "__supertype__" , None )
272271 if newtype_supertype and inspect .isfunction (typ ):
273272 metadata .setdefault ("description" , typ .__name__ )
0 commit comments