Skip to content

Commit

Permalink
fix: make function validator types positional-only (#8479)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmmmwh committed Jan 9, 2024
1 parent 56d4e92 commit 1a5d084
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions pydantic/functional_validators.py
Expand Up @@ -216,20 +216,21 @@ def __get_pydantic_core_schema__(self, source_type: Any, handler: _GetCoreSchema
if TYPE_CHECKING:

class _OnlyValueValidatorClsMethod(Protocol):
def __call__(self, __cls: Any, __value: Any) -> Any:
def __call__(self, cls: Any, value: Any, /) -> Any:
...

class _V2ValidatorClsMethod(Protocol):
def __call__(self, __cls: Any, __input_value: Any, __info: _core_schema.ValidationInfo) -> Any:
def __call__(self, cls: Any, value: Any, info: _core_schema.ValidationInfo, /) -> Any:
...

class _V2WrapValidatorClsMethod(Protocol):
def __call__(
self,
__cls: Any,
__input_value: Any,
__validator: _core_schema.ValidatorFunctionWrapHandler,
__info: _core_schema.ValidationInfo,
cls: Any,
value: Any,
handler: _core_schema.ValidatorFunctionWrapHandler,
info: _core_schema.ValidationInfo,
/,
) -> Any:
...

Expand Down Expand Up @@ -379,7 +380,10 @@ class ModelWrapValidatorHandler(_core_schema.ValidatorFunctionWrapHandler, Proto
"""@model_validator decorated function handler argument type. This is used when `mode='wrap'`."""

def __call__( # noqa: D102
self, input_value: Any, outer_location: str | int | None = None
self,
value: Any,
outer_location: str | int | None = None,
/,
) -> _ModelTypeCo: # pragma: no cover
...

Expand All @@ -395,8 +399,9 @@ def __call__( # noqa: D102
# this can be a dict, a model instance
# or anything else that gets passed to validate_python
# thus validators _must_ handle all cases
__value: Any,
__handler: ModelWrapValidatorHandler[_ModelType],
value: Any,
handler: ModelWrapValidatorHandler[_ModelType],
/,
) -> _ModelType:
...

Expand All @@ -410,9 +415,10 @@ def __call__( # noqa: D102
# this can be a dict, a model instance
# or anything else that gets passed to validate_python
# thus validators _must_ handle all cases
__value: Any,
__handler: ModelWrapValidatorHandler[_ModelType],
__info: _core_schema.ValidationInfo,
value: Any,
handler: ModelWrapValidatorHandler[_ModelType],
info: _core_schema.ValidationInfo,
/,
) -> _ModelType:
...

Expand All @@ -427,7 +433,8 @@ def __call__( # noqa: D102
# this can be a dict, a model instance
# or anything else that gets passed to validate_python
# thus validators _must_ handle all cases
__value: Any,
value: Any,
/,
) -> Any:
...

Expand All @@ -443,7 +450,8 @@ def __call__( # noqa: D102
# this can be a dict, a model instance
# or anything else that gets passed to validate_python
# thus validators _must_ handle all cases
__value: Any,
value: Any,
/,
) -> Any:
...

Expand All @@ -456,8 +464,9 @@ def __call__( # noqa: D102
# this can be a dict, a model instance
# or anything else that gets passed to validate_python
# thus validators _must_ handle all cases
__value: Any,
__info: _core_schema.ValidationInfo,
value: Any,
info: _core_schema.ValidationInfo,
/,
) -> Any:
...

Expand All @@ -471,8 +480,9 @@ def __call__( # noqa: D102
# this can be a dict, a model instance
# or anything else that gets passed to validate_python
# thus validators _must_ handle all cases
__value: Any,
__info: _core_schema.ValidationInfo,
value: Any,
info: _core_schema.ValidationInfo,
/,
) -> Any:
...

Expand Down

0 comments on commit 1a5d084

Please sign in to comment.