Closed
Description
$ git clone https://github.com/pydantic/pydantic-settings.git
$ cd pydantic-settings
$ git checkout v2.8.1
$ uv venv
$ . .venv/bin/activate
(pydantic-settings) $ uv pip install -r requirements/all.txt
(pydantic-settings) $ uv pip install -e .
(pydantic-settings) $ pytest
[…]
Results (1.94s):
395 passed
4 skipped
(pydantic-settings) $ uv pip install --upgrade typing-extensions
[…]
- pydantic==2.9.1
+ pydantic==2.11.3
- pydantic-core==2.23.3
+ pydantic-core==2.33.1
- typing-extensions==4.12.2
+ typing-extensions==4.13.2
+ typing-inspection==0.4.0
(pydantic-settings) $ pytest
[…]
============================================== FAILURES ==============================================
______________________________ test_docs_examples[docs/index.md:24-83] _______________________________
Print output changed code:
--- before
+++ after
@@ -70,37 +70,37 @@
print(Settings().model_dump())
"""
{
'auth_key': 'xxx',
'api_key': 'xxx',
- 'redis_dsn': Url('redis://user:pass@localhost:6379/1'),
- 'pg_dsn': MultiHostUrl('postgres://user:pass@localhost:5432/foobar'),
- 'amqp_dsn': Url('amqp://user:pass@localhost:5672/'),
+ 'redis_dsn': RedisDsn('redis://user:pass@localhost:6379/1'),
+ 'pg_dsn': PostgresDsn('postgres://user:pass@localhost:5432/foobar'),
+ 'amqp_dsn': AmqpDsn('amqp://user:pass@localhost:5672/'),
'special_function': math.cos,
'domains': set(),
'more_settings': {'foo': 'bar', 'apple': 1},
}
"""
____________________________ test_docs_examples[docs/index.md:1063-1100] _____________________________
example = CodeExample(source='from pydantic import BaseModel\n\nfrom pydantic_settings import CliApp, CliPositionalArg, CliSubCo...UID('b2f6e19b-835d-4e7c-9326-e69835daed33'), test_id='tests/test_docs.py::test_docs_examples[docs/index.md:1063-1100]')
eval_example = <pytest_examples.eval_example.EvalExample object at 0x7efdb2c93bd0>
tmp_path = PosixPath('/tmp/pytest-of-ben/pytest-7/test_docs_examples_docs_index_24')
mocker = <pytest_mock.plugin.MockerFixture object at 0x7efdb2b67380>
docs_test_env = <conftest.SetEnv object at 0x7efdb2e546e0>
@pytest.mark.filterwarnings('ignore:(parse_obj_as|schema_json_of|schema_of) is deprecated.*:DeprecationWarning')
@pytest.mark.skipif(bool(skip_reason), reason=skip_reason or 'not skipping')
@pytest.mark.parametrize('example', find_examples(str(DOCS_ROOT), skip=sys.platform == 'win32'), ids=str)
def test_docs_examples( # noqa C901
example: CodeExample, eval_example: EvalExample, tmp_path: Path, mocker, docs_test_env
):
eval_example.print_callback = print_callback
prefix_settings = example.prefix_settings()
test_settings = prefix_settings.get('test')
lint_settings = prefix_settings.get('lint')
if test_settings == 'skip' and lint_settings == 'skip':
pytest.skip('both test and lint skipped')
requires_settings = prefix_settings.get('requires')
if requires_settings:
major, minor = map(int, requires_settings.split('.'))
if sys.version_info < (major, minor):
pytest.skip(f'requires python {requires_settings}')
group_name = prefix_settings.get('group')
if '# ignore-above' in example.source:
eval_example.set_config(ruff_ignore=['E402'])
if group_name:
eval_example.set_config(ruff_ignore=['F821'])
# eval_example.set_config(line_length=120)
if lint_settings != 'skip':
if eval_example.update_examples:
eval_example.format(example)
else:
eval_example.lint(example)
if test_settings == 'skip':
return
group_name = prefix_settings.get('group')
d = group_globals.get(group_name)
xfail = None
if test_settings and test_settings.startswith('xfail'):
xfail = test_settings[5:].lstrip(' -')
rewrite_assertions = prefix_settings.get('rewrite_assert', 'true') == 'true'
try:
if test_settings == 'no-print-intercept':
d2 = eval_example.run(example, module_globals=d, rewrite_assertions=rewrite_assertions)
elif eval_example.update_examples:
d2 = eval_example.run_print_update(example, module_globals=d, rewrite_assertions=rewrite_assertions)
else:
> d2 = eval_example.run_print_check(example, module_globals=d, rewrite_assertions=rewrite_assertions)
tests/test_docs.py:109:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
from pydantic import BaseModel
from pydantic_settings import CliApp, CliPositionalArg, CliSubCommand
class Init(BaseModel):
directory: CliPositionalArg[str]
def cli_cmd(self) -> None:
print(f'git init "{self.directory}"')
#> git init "dir"
self.directory = 'ran the git init cli cmd'
class Clone(BaseModel):
repository: CliPositionalArg[str]
directory: CliPositionalArg[str]
def cli_cmd(self) -> None:
print(f'git clone from "{self.repository}" into "{self.directory}"')
self.directory = 'ran the clone cli cmd'
class Git(BaseModel):
clone: CliSubCommand[Clone]
init: CliSubCommand[Init]
def cli_cmd(self) -> None:
CliApp.run_subcommand(self)
> cmd = CliApp.run(Git, cli_args=['init', 'dir'])
E pydantic.warnings.PydanticDeprecatedSince211: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.
docs/index.md:1095: PydanticDeprecatedSince211
____________________________ test_docs_examples[docs/index.md:2054-2079] _____________________________
Print output changed code:
--- before
+++ after
@@ -2073,2060 +2073,2060 @@
) -> Tuple[PydanticBaseSettingsSource, ...]:
return env_settings, init_settings, file_secret_settings
print(Settings(database_dsn='postgres://postgres@localhost:5432/kwargs_db'))
-#> database_dsn=MultiHostUrl('postgres://postgres@localhost:5432/kwargs_db')
+#> database_dsn=PostgresDsn('postgres://postgres@localhost:5432/kwargs_db')
_______________________________ test_cli_metavar_format_type_alias_312 _______________________________
@pytest.mark.skipif(sys.version_info < (3, 12), reason='requires python 3.12 or higher')
def test_cli_metavar_format_type_alias_312():
> exec(
"""
type TypeAliasInt = int
assert CliSettingsSource(SimpleSettings)._metavar_format(TypeAliasInt) == 'TypeAliasInt'
"""
)
tests/test_source_cli.py:2068:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> ???
E AssertionError
<string>:3: AssertionError
____________________________________________ test_cli_app ____________________________________________
def test_cli_app():
class Init(BaseModel):
directory: CliPositionalArg[str]
def cli_cmd(self) -> None:
self.directory = 'ran Init.cli_cmd'
def alt_cmd(self) -> None:
self.directory = 'ran Init.alt_cmd'
class Clone(BaseModel):
repository: CliPositionalArg[str]
directory: CliPositionalArg[str]
def cli_cmd(self) -> None:
self.repository = 'ran Clone.cli_cmd'
def alt_cmd(self) -> None:
self.repository = 'ran Clone.alt_cmd'
class Git(BaseModel):
clone: CliSubCommand[Clone]
init: CliSubCommand[Init]
def cli_cmd(self) -> None:
CliApp.run_subcommand(self)
def alt_cmd(self) -> None:
CliApp.run_subcommand(self, cli_cmd_method_name='alt_cmd')
> assert CliApp.run(Git, cli_args=['init', 'dir']).model_dump() == {
'clone': None,
'init': {'directory': 'ran Init.cli_cmd'},
}
tests/test_source_cli.py:2106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pydantic_settings/main.py:574: in run
for field_name, field_info in model.model_fields.items():
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pydantic._internal._utils.deprecated_instance_property object at 0x7efdb5278830>
instance = CliAppBaseSettings(clone=None, init=Init(directory='dir'))
objtype = <class 'pydantic_settings.main.CliApp.run.<locals>.CliAppBaseSettings'>
def __get__(self, instance: _ModelT | None, objtype: type[_ModelT]) -> _RT:
if instance is not None:
attr_name = self.fget.__name__ if sys.version_info >= (3, 10) else self.fget.__func__.__name__
> warnings.warn(
f'Accessing the {attr_name!r} attribute on the instance is deprecated. '
'Instead, you should access this attribute from the model class.',
category=PydanticDeprecatedSince211,
stacklevel=2,
)
E pydantic.warnings.PydanticDeprecatedSince211: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.
.venv/lib64/python3.13/site-packages/pydantic/_internal/_utils.py:425: PydanticDeprecatedSince211
______________________________________ test_cli_app_exceptions _______________________________________
def test_cli_app_exceptions():
with pytest.raises(
SettingsError, match='Error: NotPydanticModel is not subclass of BaseModel or pydantic.dataclasses.dataclass'
):
class NotPydanticModel: ...
CliApp.run(NotPydanticModel)
with pytest.raises(
SettingsError,
match=re.escape('Error: `cli_args` must be list[str] or None when `cli_settings_source` is not used'),
):
class Cfg(BaseModel): ...
CliApp.run(Cfg, cli_args={'my_arg': 'hello'})
with pytest.raises(SettingsError, match='Error: Child class is missing cli_cmd entrypoint'):
class Child(BaseModel):
val: str
class Root(BaseModel):
child: CliSubCommand[Child]
def cli_cmd(self) -> None:
CliApp.run_subcommand(self)
> CliApp.run(Root, cli_args=['child', '--val=hello'])
tests/test_source_cli.py:2176:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pydantic_settings/main.py:574: in run
for field_name, field_info in model.model_fields.items():
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pydantic._internal._utils.deprecated_instance_property object at 0x7efdb5278830>
instance = CliAppBaseSettings(child=Child(val='hello'))
objtype = <class 'pydantic_settings.main.CliApp.run.<locals>.CliAppBaseSettings'>
def __get__(self, instance: _ModelT | None, objtype: type[_ModelT]) -> _RT:
if instance is not None:
attr_name = self.fget.__name__ if sys.version_info >= (3, 10) else self.fget.__func__.__name__
> warnings.warn(
f'Accessing the {attr_name!r} attribute on the instance is deprecated. '
'Instead, you should access this attribute from the model class.',
category=PydanticDeprecatedSince211,
stacklevel=2,
)
E pydantic.warnings.PydanticDeprecatedSince211: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.
.venv/lib64/python3.13/site-packages/pydantic/_internal/_utils.py:425: PydanticDeprecatedSince211
_________________________________ test_cli_mutually_exclusive_group __________________________________
capsys = <_pytest.capture.CaptureFixture object at 0x7efdb3ca3330>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7efdb2f707c0>
def test_cli_mutually_exclusive_group(capsys, monkeypatch):
class Circle(CliMutuallyExclusiveGroup):
radius: Optional[float] = 21
diameter: Optional[float] = 22
perimeter: Optional[float] = 23
class Settings(BaseModel):
circle_optional: Circle = Circle(radius=None, diameter=None, perimeter=24)
circle_required: Circle
> CliApp.run(Settings, cli_args=['--circle-required.radius=1', '--circle-optional.radius=1']).model_dump() == {
'circle_optional': {'radius': 1, 'diameter': 22, 'perimeter': 24},
'circle_required': {'radius': 1, 'diameter': 22, 'perimeter': 23},
}
tests/test_source_cli.py:2210:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pydantic_settings/main.py:574: in run
for field_name, field_info in model.model_fields.items():
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pydantic._internal._utils.deprecated_instance_property object at 0x7efdb5278830>
instance = CliAppBaseSettings(circle_optional=Circle(radius=1.0, diameter=None, perimeter=24.0), circle_required=Circle(radius=1.0, diameter=22, perimeter=23))
objtype = <class 'pydantic_settings.main.CliApp.run.<locals>.CliAppBaseSettings'>
def __get__(self, instance: _ModelT | None, objtype: type[_ModelT]) -> _RT:
if instance is not None:
attr_name = self.fget.__name__ if sys.version_info >= (3, 10) else self.fget.__func__.__name__
> warnings.warn(
f'Accessing the {attr_name!r} attribute on the instance is deprecated. '
'Instead, you should access this attribute from the model class.',
category=PydanticDeprecatedSince211,
stacklevel=2,
)
E pydantic.warnings.PydanticDeprecatedSince211: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.
.venv/lib64/python3.13/site-packages/pydantic/_internal/_utils.py:425: PydanticDeprecatedSince211
____________________________ test_cli_mutually_exclusive_group_exceptions ____________________________
def test_cli_mutually_exclusive_group_exceptions():
class Circle(CliMutuallyExclusiveGroup):
radius: Optional[float] = 21
diameter: Optional[float] = 22
perimeter: Optional[float] = 23
class Settings(BaseSettings):
circle: Circle
parser = CliDummyParser()
with pytest.raises(
SettingsError,
match='cannot connect CLI settings source root parser: group object is missing add_mutually_exclusive_group but is needed for connecting',
):
CliSettingsSource(
Settings,
root_parser=parser,
parse_args_method=CliDummyParser.parse_args,
add_argument_method=CliDummyParser.add_argument,
add_argument_group_method=CliDummyParser.add_argument_group,
add_parser_method=CliDummySubParsers.add_parser,
add_subparsers_method=CliDummyParser.add_subparsers,
)
class SubModel(BaseModel):
pass
class SettingsInvalidUnion(BaseSettings):
union: Union[Circle, SubModel]
with pytest.raises(SettingsError, match='cannot use union with CliMutuallyExclusiveGroup'):
CliApp.run(SettingsInvalidUnion)
class CircleInvalidSubModel(Circle):
square: Optional[SubModel] = None
class SettingsInvalidOptSubModel(BaseModel):
circle: CircleInvalidSubModel = CircleInvalidSubModel()
class SettingsInvalidReqSubModel(BaseModel):
circle: CircleInvalidSubModel
for settings in [SettingsInvalidOptSubModel, SettingsInvalidReqSubModel]:
with pytest.raises(SettingsError, match='cannot have nested models in a CliMutuallyExclusiveGroup'):
CliApp.run(settings)
class CircleRequiredField(Circle):
length: float
class SettingsOptCircleReqField(BaseModel):
circle: CircleRequiredField = CircleRequiredField(length=2)
> assert CliApp.run(SettingsOptCircleReqField, cli_args=[]).model_dump() == {
'circle': {'diameter': 22.0, 'length': 2.0, 'perimeter': 23.0, 'radius': 21.0}
}
tests/test_source_cli.py:2326:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pydantic_settings/main.py:574: in run
for field_name, field_info in model.model_fields.items():
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pydantic._internal._utils.deprecated_instance_property object at 0x7efdb5278830>
instance = CliAppBaseSettings(circle=CircleRequiredField(radius=21.0, diameter=22.0, perimeter=23.0, length=2.0))
objtype = <class 'pydantic_settings.main.CliApp.run.<locals>.CliAppBaseSettings'>
def __get__(self, instance: _ModelT | None, objtype: type[_ModelT]) -> _RT:
if instance is not None:
attr_name = self.fget.__name__ if sys.version_info >= (3, 10) else self.fget.__func__.__name__
> warnings.warn(
f'Accessing the {attr_name!r} attribute on the instance is deprecated. '
'Instead, you should access this attribute from the model class.',
category=PydanticDeprecatedSince211,
stacklevel=2,
)
E pydantic.warnings.PydanticDeprecatedSince211: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.
.venv/lib64/python3.13/site-packages/pydantic/_internal/_utils.py:425: PydanticDeprecatedSince211
________________________________________ test_cli_kebab_case _________________________________________
capsys = <_pytest.capture.CaptureFixture object at 0x7efdb2c14870>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7efdb2f96ac0>
def test_cli_kebab_case(capsys, monkeypatch):
class DeepSubModel(BaseModel):
deep_pos_arg: CliPositionalArg[str]
deep_arg: str
class SubModel(BaseModel):
sub_subcmd: CliSubCommand[DeepSubModel]
sub_arg: str
class Root(BaseModel):
root_subcmd: CliSubCommand[SubModel]
root_arg: str
> assert CliApp.run(
Root,
cli_args=[
'--root-arg=hi',
'root-subcmd',
'--sub-arg=hello',
'sub-subcmd',
'hey',
'--deep-arg=bye',
],
).model_dump() == {
'root_arg': 'hi',
'root_subcmd': {
'sub_arg': 'hello',
'sub_subcmd': {'deep_pos_arg': 'hey', 'deep_arg': 'bye'},
},
}
tests/test_source_cli.py:2386:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pydantic_settings/main.py:574: in run
for field_name, field_info in model.model_fields.items():
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pydantic._internal._utils.deprecated_instance_property object at 0x7efdb5278830>
instance = CliAppBaseSettings(root_subcmd=SubModel(sub_subcmd=DeepSubModel(deep_pos_arg='hey', deep_arg='bye'), sub_arg='hello'), root_arg='hi')
objtype = <class 'pydantic_settings.main.CliApp.run.<locals>.CliAppBaseSettings'>
def __get__(self, instance: _ModelT | None, objtype: type[_ModelT]) -> _RT:
if instance is not None:
attr_name = self.fget.__name__ if sys.version_info >= (3, 10) else self.fget.__func__.__name__
> warnings.warn(
f'Accessing the {attr_name!r} attribute on the instance is deprecated. '
'Instead, you should access this attribute from the model class.',
category=PydanticDeprecatedSince211,
stacklevel=2,
)
E pydantic.warnings.PydanticDeprecatedSince211: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.
.venv/lib64/python3.13/site-packages/pydantic/_internal/_utils.py:425: PydanticDeprecatedSince211
_____________________________________________ test_repr ______________________________________________
def test_repr() -> None:
> source = JsonConfigSettingsSource(BaseSettings(), Path('config.json'))
tests/test_source_json.py:20:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pydantic_settings/sources.py:2088: in __init__
super().__init__(settings_cls, self.json_data)
pydantic_settings/sources.py:393: in __init__
for field_name, field_info in settings_cls.model_fields.items():
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pydantic._internal._utils.deprecated_instance_property object at 0x7efdb5278830>
instance = BaseSettings(), objtype = <class 'pydantic_settings.main.BaseSettings'>
def __get__(self, instance: _ModelT | None, objtype: type[_ModelT]) -> _RT:
if instance is not None:
attr_name = self.fget.__name__ if sys.version_info >= (3, 10) else self.fget.__func__.__name__
> warnings.warn(
f'Accessing the {attr_name!r} attribute on the instance is deprecated. '
'Instead, you should access this attribute from the model class.',
category=PydanticDeprecatedSince211,
stacklevel=2,
)
E pydantic.warnings.PydanticDeprecatedSince211: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.
.venv/lib64/python3.13/site-packages/pydantic/_internal/_utils.py:425: PydanticDeprecatedSince211
_____________________________________________ test_repr ______________________________________________
def test_repr() -> None:
> source = TomlConfigSettingsSource(BaseSettings(), Path('config.toml'))
tests/test_source_toml.py:26:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pydantic_settings/sources.py:2110: in __init__
super().__init__(settings_cls, self.toml_data)
pydantic_settings/sources.py:393: in __init__
for field_name, field_info in settings_cls.model_fields.items():
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pydantic._internal._utils.deprecated_instance_property object at 0x7efdb5278830>
instance = BaseSettings(), objtype = <class 'pydantic_settings.main.BaseSettings'>
def __get__(self, instance: _ModelT | None, objtype: type[_ModelT]) -> _RT:
if instance is not None:
attr_name = self.fget.__name__ if sys.version_info >= (3, 10) else self.fget.__func__.__name__
> warnings.warn(
f'Accessing the {attr_name!r} attribute on the instance is deprecated. '
'Instead, you should access this attribute from the model class.',
category=PydanticDeprecatedSince211,
stacklevel=2,
)
E pydantic.warnings.PydanticDeprecatedSince211: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.
.venv/lib64/python3.13/site-packages/pydantic/_internal/_utils.py:425: PydanticDeprecatedSince211
_____________________________________________ test_repr ______________________________________________
def test_repr() -> None:
> source = YamlConfigSettingsSource(BaseSettings(), Path('config.yaml'))
tests/test_source_yaml.py:25:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pydantic_settings/sources.py:2187: in __init__
super().__init__(settings_cls, self.yaml_data)
pydantic_settings/sources.py:393: in __init__
for field_name, field_info in settings_cls.model_fields.items():
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pydantic._internal._utils.deprecated_instance_property object at 0x7efdb5278830>
instance = BaseSettings(), objtype = <class 'pydantic_settings.main.BaseSettings'>
def __get__(self, instance: _ModelT | None, objtype: type[_ModelT]) -> _RT:
if instance is not None:
attr_name = self.fget.__name__ if sys.version_info >= (3, 10) else self.fget.__func__.__name__
> warnings.warn(
f'Accessing the {attr_name!r} attribute on the instance is deprecated. '
'Instead, you should access this attribute from the model class.',
category=PydanticDeprecatedSince211,
stacklevel=2,
)
E pydantic.warnings.PydanticDeprecatedSince211: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.
.venv/lib64/python3.13/site-packages/pydantic/_internal/_utils.py:425: PydanticDeprecatedSince211
Summary of Failures
┏━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┓
┃ File ┃ Function ┃ Function Line ┃ Error Line ┃ Error ┃
┡━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━┩
│ tests/test_docs.py │ test_docs_exampl… │ 57 │ │ │
│ tests/test_docs.py │ test_docs_exampl… │ 57 │ 109 │ PydanticDeprecate… │
│ tests/test_docs.py │ test_docs_exampl… │ 57 │ │ │
│ tests/test_source… │ test_cli_metavar… │ 2066 │ 2068 │ AssertionError │
│ tests/test_source… │ test_cli_app │ 2076 │ 2106 │ PydanticDeprecate… │
│ tests/test_source… │ test_cli_app_exc… │ 2147 │ 2176 │ PydanticDeprecate… │
│ tests/test_source… │ test_cli_mutuall… │ 2200 │ 2210 │ PydanticDeprecate… │
│ tests/test_source… │ test_cli_mutuall… │ 2274 │ 2326 │ PydanticDeprecate… │
│ tests/test_source… │ test_cli_kebab_c… │ 2373 │ 2386 │ PydanticDeprecate… │
│ tests/test_source… │ test_repr │ 19 │ 20 │ PydanticDeprecate… │
│ tests/test_source… │ test_repr │ 25 │ 26 │ PydanticDeprecate… │
│ tests/test_source… │ test_repr │ 24 │ 25 │ PydanticDeprecate… │
└──────────────────────┴─────────────────────┴─────────────────┴──────────────┴──────────────────────┘
Results (1.66s):
12 failed
383 passed
4 skipped
One of these is #591. Most of the rest are due to pydantic.warnings.PydanticDeprecatedSince211
being treated as an error. What’s left is test_docs_examples[docs/index.md:24-83]
and test_docs_examples[docs/index.md:2054-2079]
, which look similar to each other.