From b1ea695195374d2e0dfc3257e0739ebe3091d6eb Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Tue, 10 Sep 2024 20:26:39 +0200 Subject: [PATCH] Fix TypeError introduced in 2.5 --- pydantic_settings/sources.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydantic_settings/sources.py b/pydantic_settings/sources.py index c793091..30e7fa3 100644 --- a/pydantic_settings/sources.py +++ b/pydantic_settings/sources.py @@ -2115,7 +2115,7 @@ def read_env_file( def _annotation_is_complex(annotation: type[Any] | None, metadata: list[Any]) -> bool: # If the model is a root model, the root annotation should be used to # evaluate the complexity. - if isinstance(annotation, type) and issubclass(annotation, RootModel): + if annotation is not None and inspect.isclass(annotation) and issubclass(annotation, RootModel): # In some rare cases (see test_root_model_as_field), # the root attribute is not available. For these cases, python 3.8 and 3.9 # return 'RootModelRootType'.