-
-
Notifications
You must be signed in to change notification settings - Fork 104
Closed
Labels
duplicateThis issue or pull request already existsThis issue or pull request already exists
Description
After updating to pydantic-settings 2.5.0, I found that setting a attribute of a BaseSettings class to frozenset[str]
or set[str]
would raise TypeError: issubclass() arg 1 must be a class
, which looks to have been introduced in this commit
MWE
from pydantic_settings import BaseSettings
class ExampleConfig(BaseSettings):
dependencies_to_build_badges: frozenset[str] = frozenset({
"dep_1",
"dep_2",
})
def test_config_init():
ExampleConfig()
traceback from the example
def test_config_init():
> ExampleConfig()
tests/test_benchmark_runner.py:12:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.venv/lib/python3.10/site-packages/pydantic_settings/main.py:153: in __init__
**__pydantic_self__._settings_build_values(
.venv/lib/python3.10/site-packages/pydantic_settings/main.py:357: in _settings_build_values
source_state = source()
.venv/lib/python3.10/site-packages/pydantic_settings/sources.py:545: in __call__
field_value = self.prepare_field_value(field_name, field, field_value, value_is_complex)
.venv/lib/python3.10/site-packages/pydantic_settings/sources.py:738: in prepare_field_value
is_complex, allow_parse_failure = self._field_is_complex(field)
.venv/lib/python3.10/site-packages/pydantic_settings/sources.py:771: in _field_is_complex
if self.field_is_complex(field):
.venv/lib/python3.10/site-packages/pydantic_settings/sources.py:276: in field_is_complex
return _annotation_is_complex(field.annotation, field.metadata)
.venv/lib/python3.10/site-packages/pydantic_settings/sources.py:2118: in _annotation_is_complex
if isinstance(annotation, type) and issubclass(annotation, RootModel):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'pydantic.root_model.RootModel'>, subclass = set[str]
def __subclasscheck__(cls, subclass):
"""Override for issubclass(subclass, cls)."""
> return _abc_subclasscheck(cls, subclass)
E TypeError: issubclass() arg 1 must be a class
../../.pyenv/versions/3.10.13/lib/python3.10/abc.py:123: TypeError
Metadata
Metadata
Assignees
Labels
duplicateThis issue or pull request already existsThis issue or pull request already exists