File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 34
34
import tomllib # pragma: no cover
35
35
36
36
37
+ # Note: Actually 'field_type' can either be a type of a typing special form,
38
+ # but there is no way yet to annotate typing special forms.
39
+ # This is the source of a lot of the casts and suppressions in this function.
37
40
def _collect_type (field_type : type , context : str ) -> type | Binder [Any ]:
38
41
"""
39
42
Verify and streamline a type annotation.
@@ -45,7 +48,7 @@ def _collect_type(field_type: type, context: str) -> type | Binder[Any]:
45
48
"""
46
49
origin = get_origin (field_type )
47
50
if origin is None :
48
- if field_type is Any :
51
+ if field_type is Any : # type: ignore[comparison-overlap]
49
52
return object
50
53
elif not isinstance (field_type , type ):
51
54
raise TypeError (f"Annotation for field '{ context } ' is not a type" )
@@ -105,7 +108,7 @@ def _collect_type(field_type: type, context: str) -> type | Binder[Any]:
105
108
for base in bases :
106
109
if not isinstance (base , type ):
107
110
raise TypeError (f"type[...] annotation for '{ context } ' must have a type as its argument" )
108
- collected_types .append (type [base ])
111
+ collected_types .append (cast ( type [Any ], type [ base ]) )
109
112
return reduce (operator .__or__ , collected_types )
110
113
else :
111
114
raise TypeError (f"Field '{ context } ' has unsupported generic type '{ origin .__name__ } '" )
You can’t perform that action at this time.
0 commit comments