Coverage for /pythoncovmergedfiles/medio/medio/src/pydantic/pydantic/validate_call.py: 53%
19 statements
« prev ^ index » next coverage.py v7.2.3, created at 2023-04-27 07:38 +0000
« prev ^ index » next coverage.py v7.2.3, created at 2023-04-27 07:38 +0000
1from __future__ import annotations as _annotations
3from typing import TYPE_CHECKING, Any, Callable, TypeVar, overload
5from ._internal import _validate_call
7__all__ = ('validate_call',)
9if TYPE_CHECKING:
10 from .config import ConfigDict
12 AnyCallableT = TypeVar('AnyCallableT', bound=Callable[..., Any])
15@overload
16def validate_call(
17 *, config: ConfigDict | None = None, validate_return: bool = False
18) -> Callable[[AnyCallableT], AnyCallableT]:
19 ...
22@overload
23def validate_call(__func: AnyCallableT) -> AnyCallableT:
24 ...
27def validate_call(
28 __func: AnyCallableT | None = None,
29 *,
30 config: ConfigDict | None = None,
31 validate_return: bool = False,
32) -> AnyCallableT | Callable[[AnyCallableT], AnyCallableT]:
33 """
34 Decorator to validate the arguments passed to a function, and optionally the return value.
35 """
37 def validate(function: AnyCallableT) -> AnyCallableT:
38 return _validate_call.ValidateCallWrapper(function, config, validate_return) # type: ignore
40 if __func:
41 return validate(__func)
42 else:
43 return validate