@@ -2115,13 +2115,16 @@ def read_env_file(
2115
2115
def _annotation_is_complex (annotation : type [Any ] | None , metadata : list [Any ]) -> bool :
2116
2116
# If the model is a root model, the root annotation should be used to
2117
2117
# evaluate the complexity.
2118
- if annotation is not None and inspect .isclass (annotation ) and issubclass (annotation , RootModel ):
2119
- # In some rare cases (see test_root_model_as_field),
2120
- # the root attribute is not available. For these cases, python 3.8 and 3.9
2121
- # return 'RootModelRootType'.
2122
- root_annotation = annotation .__annotations__ .get ('root' , None )
2123
- if root_annotation is not None and root_annotation != 'RootModelRootType' :
2124
- annotation = root_annotation
2118
+ try :
2119
+ if annotation is not None and issubclass (annotation , RootModel ):
2120
+ # In some rare cases (see test_root_model_as_field),
2121
+ # the root attribute is not available. For these cases, python 3.8 and 3.9
2122
+ # return 'RootModelRootType'.
2123
+ root_annotation = annotation .__annotations__ .get ('root' , None )
2124
+ if root_annotation is not None and root_annotation != 'RootModelRootType' :
2125
+ annotation = root_annotation
2126
+ except TypeError :
2127
+ pass
2125
2128
2126
2129
if any (isinstance (md , Json ) for md in metadata ): # type: ignore[misc]
2127
2130
return False
0 commit comments