Skip to content

Commit

Permalink
Update pydantic to 2.0b1 (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
hramezani authored Jun 2, 2023
1 parent 56ba90a commit d21c82a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions pydantic_settings/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,5 @@ def _settings_build_values(
env_file_encoding=None,
env_nested_delimiter=None,
secrets_dir=None,
protected_namespaces=('model_', 'settings_'),
)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ classifiers = [
]
requires-python = '>=3.7'
dependencies = [
'pydantic>=2.0a4',
'pydantic>=2.0b1',
'python-dotenv>=0.21.0',
]
dynamic = ['version']
Expand Down
4 changes: 2 additions & 2 deletions requirements/pyproject.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#
annotated-types==0.4.0
# via pydantic
pydantic==2.0a4
pydantic==2.0b1
# via pydantic-settings (pyproject.toml)
pydantic-core==0.30.0
pydantic-core==0.38.0
# via pydantic
python-dotenv==0.21.1
# via pydantic-settings (pyproject.toml)
Expand Down
16 changes: 16 additions & 0 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1614,3 +1614,19 @@ class Settings(BaseSettings):
assert s.v0 == 'v0'
assert s.sub_model.v1 == 'v1'
assert s.sub_model.v2 == b'v2'


def test_protected_namespace_defaults():
# pydantic default
with pytest.raises(NameError, match='Field "model_prefixed_field" has conflict with protected namespace "model_"'):

class Model(BaseSettings):
model_prefixed_field: str

# pydantic-settings default
with pytest.raises(
NameError, match='Field "settings_prefixed_field" has conflict with protected namespace "settings_"'
):

class Model1(BaseSettings):
settings_prefixed_field: str

0 comments on commit d21c82a

Please sign in to comment.