Skip to content

Commit e73b349

Browse files
authored
Revert "Fix context not passed to field validators bug (#417)" (#459)
1 parent a37d07c commit e73b349

File tree

2 files changed

+0
-20
lines changed

2 files changed

+0
-20
lines changed

pydantic_settings/main.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,6 @@ def __init__(
193193
)
194194
)
195195

196-
__init__.__pydantic_base_init__ = True # type: ignore
197-
198196
@classmethod
199197
def settings_customise_sources(
200198
cls,

tests/test_settings.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
SecretStr,
2323
Tag,
2424
ValidationError,
25-
ValidationInfo,
26-
field_validator,
2725
)
2826
from pydantic import (
2927
dataclasses as pydantic_dataclasses,
@@ -2774,22 +2772,6 @@ class Settings(BaseSettings):
27742772
assert s.model_dump() == {'nested': {'foo': ['one', 'two']}}
27752773

27762774

2777-
def test_validation_context():
2778-
class Settings(BaseSettings):
2779-
foo: str
2780-
2781-
@field_validator('foo')
2782-
@classmethod
2783-
def test_validator(cls, v: str, info: ValidationInfo):
2784-
context = info.context
2785-
assert context == {'foo': 'bar'}
2786-
return v
2787-
2788-
s = Settings.model_validate({'foo': 'foo bar'}, context={'foo': 'bar'})
2789-
assert s.foo == 'foo bar'
2790-
assert s.model_dump() == {'foo': 'foo bar'}
2791-
2792-
27932775
def test_nested_model_field_with_alias_choices(env):
27942776
class NestedSettings(BaseModel):
27952777
foo: List[str] = Field(alias=AliasChoices('fooalias', 'foo-alias'))

0 commit comments

Comments
 (0)