From e73b349e3b9b0d40b599b1314d6759abaa2ab87c Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Fri, 1 Nov 2024 11:44:31 +0100 Subject: [PATCH] Revert "Fix context not passed to field validators bug (#417)" (#459) --- pydantic_settings/main.py | 2 -- tests/test_settings.py | 18 ------------------ 2 files changed, 20 deletions(-) diff --git a/pydantic_settings/main.py b/pydantic_settings/main.py index f693627..723d6d5 100644 --- a/pydantic_settings/main.py +++ b/pydantic_settings/main.py @@ -193,8 +193,6 @@ def __init__( ) ) - __init__.__pydantic_base_init__ = True # type: ignore - @classmethod def settings_customise_sources( cls, diff --git a/tests/test_settings.py b/tests/test_settings.py index e6a1857..937047b 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -22,8 +22,6 @@ SecretStr, Tag, ValidationError, - ValidationInfo, - field_validator, ) from pydantic import ( dataclasses as pydantic_dataclasses, @@ -2774,22 +2772,6 @@ class Settings(BaseSettings): assert s.model_dump() == {'nested': {'foo': ['one', 'two']}} -def test_validation_context(): - class Settings(BaseSettings): - foo: str - - @field_validator('foo') - @classmethod - def test_validator(cls, v: str, info: ValidationInfo): - context = info.context - assert context == {'foo': 'bar'} - return v - - s = Settings.model_validate({'foo': 'foo bar'}, context={'foo': 'bar'}) - assert s.foo == 'foo bar' - assert s.model_dump() == {'foo': 'foo bar'} - - def test_nested_model_field_with_alias_choices(env): class NestedSettings(BaseModel): foo: List[str] = Field(alias=AliasChoices('fooalias', 'foo-alias'))