Coverage for fastapi/_compat/model_field.py: 100%
20 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-12-04 08:29 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-12-04 08:29 +0000
1from typing import ( 1abcdefg
2 Any,
3 Dict,
4 List,
5 Tuple,
6 Union,
7)
9from fastapi.types import IncEx 1abcdefg
10from pydantic.fields import FieldInfo 1abcdefg
11from typing_extensions import Literal, Protocol 1abcdefg
14class ModelField(Protocol): 1abcdefg
15 field_info: "FieldInfo" 1abcdefg
16 name: str 1abcdefg
17 mode: Literal["validation", "serialization"] = "validation" 1abcdefg
18 _version: Literal["v1", "v2"] = "v1" 1abcdefg
20 @property 1abcdefg
21 def alias(self) -> str: ... 1abcdefg
23 @property 1abcdefg
24 def required(self) -> bool: ... 1abcdefg
26 @property 1abcdefg
27 def default(self) -> Any: ... 1abcdefg
29 @property 1abcdefg
30 def type_(self) -> Any: ... 1abcdefg
32 def get_default(self) -> Any: ... 1abcdefg
34 def validate( 1abcdefg
35 self,
36 value: Any,
37 values: Dict[str, Any] = {}, # noqa: B006
38 *,
39 loc: Tuple[Union[int, str], ...] = (),
40 ) -> Tuple[Any, Union[List[Dict[str, Any]], None]]: ...
42 def serialize( 1abcdefg
43 self,
44 value: Any,
45 *,
46 mode: Literal["json", "python"] = "json",
47 include: Union[IncEx, None] = None,
48 exclude: Union[IncEx, None] = None,
49 by_alias: bool = True,
50 exclude_unset: bool = False,
51 exclude_defaults: bool = False,
52 exclude_none: bool = False,
53 ) -> Any: ...