Skip to content

Commit d21c82a

Browse files
authored
Update pydantic to 2.0b1 (#64)
1 parent 56ba90a commit d21c82a

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

pydantic_settings/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,5 @@ def _settings_build_values(
127127
env_file_encoding=None,
128128
env_nested_delimiter=None,
129129
secrets_dir=None,
130+
protected_namespaces=('model_', 'settings_'),
130131
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ classifiers = [
4040
]
4141
requires-python = '>=3.7'
4242
dependencies = [
43-
'pydantic>=2.0a4',
43+
'pydantic>=2.0b1',
4444
'python-dotenv>=0.21.0',
4545
]
4646
dynamic = ['version']

requirements/pyproject.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#
77
annotated-types==0.4.0
88
# via pydantic
9-
pydantic==2.0a4
9+
pydantic==2.0b1
1010
# via pydantic-settings (pyproject.toml)
11-
pydantic-core==0.30.0
11+
pydantic-core==0.38.0
1212
# via pydantic
1313
python-dotenv==0.21.1
1414
# via pydantic-settings (pyproject.toml)

tests/test_settings.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,3 +1614,19 @@ class Settings(BaseSettings):
16141614
assert s.v0 == 'v0'
16151615
assert s.sub_model.v1 == 'v1'
16161616
assert s.sub_model.v2 == b'v2'
1617+
1618+
1619+
def test_protected_namespace_defaults():
1620+
# pydantic default
1621+
with pytest.raises(NameError, match='Field "model_prefixed_field" has conflict with protected namespace "model_"'):
1622+
1623+
class Model(BaseSettings):
1624+
model_prefixed_field: str
1625+
1626+
# pydantic-settings default
1627+
with pytest.raises(
1628+
NameError, match='Field "settings_prefixed_field" has conflict with protected namespace "settings_"'
1629+
):
1630+
1631+
class Model1(BaseSettings):
1632+
settings_prefixed_field: str

0 commit comments

Comments
 (0)