Skip to content

Commit

Permalink
Update to Pydantic 2.0.1 (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
hramezani authored Jul 5, 2023
1 parent 3f613ae commit 1e79acc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
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.0',
'pydantic>=2.0.1',
'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.0
pydantic==2.0.1
# via pydantic-settings (pyproject.toml)
pydantic-core==2.0.1
pydantic-core==2.0.2
# via pydantic
python-dotenv==0.21.1
# via pydantic-settings (pyproject.toml)
Expand Down
16 changes: 14 additions & 2 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1620,19 +1620,31 @@ class Settings(BaseSettings):

def test_protected_namespace_defaults():
# pydantic default
with pytest.raises(NameError, match='Field "model_prefixed_field" has conflict with protected namespace "model_"'):
with pytest.warns(UserWarning, 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_"'
UserWarning, match='Field "settings_prefixed_field" has conflict with protected namespace "settings_"'
):

class Model1(BaseSettings):
settings_prefixed_field: str

with pytest.raises(
NameError,
match=(
'Field "settings_customise_sources" conflicts with member <bound method '
"BaseSettings.settings_customise_sources of <class 'pydantic_settings.main.BaseSettings'>> "
'of protected namespace "settings_".'
),
):

class Model2(BaseSettings):
settings_customise_sources: str


def test_case_sensitive_from_args(monkeypatch):
class Settings(BaseSettings):
Expand Down

0 comments on commit 1e79acc

Please sign in to comment.