Skip to content

Commit

Permalink
Fix backwards compatibility of type-checking when using deprecated `F…
Browse files Browse the repository at this point in the history
…ieldValidationInfo` (#995)
  • Loading branch information
sisp committed Sep 29, 2023
1 parent a8fb1e3 commit f3c5714
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/pydantic_core/core_schema.py
Expand Up @@ -3909,6 +3909,9 @@ def general_plain_validator_function(*args, **kwargs):
'FieldWrapValidatorFunction': WithInfoWrapValidatorFunction,
}

if TYPE_CHECKING:
FieldValidationInfo = ValidationInfo


def __getattr__(attr_name: str) -> object:
new_attr = _deprecated_import_lookup.get(attr_name)
Expand Down
4 changes: 4 additions & 0 deletions tests/test_typing.py
Expand Up @@ -23,6 +23,10 @@ def foo(bar: str) -> None:
...


def validator_deprecated(value: Any, info: core_schema.FieldValidationInfo) -> None:
...


def validator(value: Any, info: core_schema.ValidationInfo) -> None:
...

Expand Down

0 comments on commit f3c5714

Please sign in to comment.