Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Pydantic 2.0.1 #101

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1619,19 +1619,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