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 3434 import tomllib # pragma: no cover
3535
3636
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.
3740def _collect_type (field_type : type , context : str ) -> type | Binder [Any ]:
3841 """
3942 Verify and streamline a type annotation.
@@ -45,7 +48,7 @@ def _collect_type(field_type: type, context: str) -> type | Binder[Any]:
4548 """
4649 origin = get_origin (field_type )
4750 if origin is None :
48- if field_type is Any :
51+ if field_type is Any : # type: ignore[comparison-overlap]
4952 return object
5053 elif not isinstance (field_type , type ):
5154 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]:
105108 for base in bases :
106109 if not isinstance (base , type ):
107110 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 ]) )
109112 return reduce (operator .__or__ , collected_types )
110113 else :
111114 raise TypeError (f"Field '{ context } ' has unsupported generic type '{ origin .__name__ } '" )
You can’t perform that action at this time.
0 commit comments