MCPcopy
hub / github.com/pydantic/pydantic / Field

Function Field

pydantic/fields.py:925–963  ·  pydantic/fields.py::Field
(
    default: ellipsis,  # noqa: F821  # TODO: use `_typing_extra.EllipsisType` when we drop Py3.9
    *,
    alias: str | None = _Unset,
    alias_priority: int | None = _Unset,
    validation_alias: str | AliasPath | AliasChoices | None = _Unset,
    serialization_alias: str | None = _Unset,
    title: str | None = _Unset,
    field_title_generator: Callable[[str, FieldInfo], str] | None = _Unset,
    description: str | None = _Unset,
    examples: list[Any] | None = _Unset,
    exclude: bool | None = _Unset,
    exclude_if: Callable[[Any], bool] | None = _Unset,
    discriminator: str | types.Discriminator | None = _Unset,
    deprecated: Deprecated | str | bool | None = _Unset,
    json_schema_extra: JsonDict | Callable[[JsonDict], None] | None = _Unset,
    frozen: bool | None = _Unset,
    validate_default: bool | None = _Unset,
    repr: bool = _Unset,
    init: bool | None = _Unset,
    init_var: bool | None = _Unset,
    kw_only: bool | None = _Unset,
    pattern: str | re.Pattern[str] | None = _Unset,
    strict: bool | None = _Unset,
    coerce_numbers_to_str: bool | None = _Unset,
    gt: annotated_types.SupportsGt | None = _Unset,
    ge: annotated_types.SupportsGe | None = _Unset,
    lt: annotated_types.SupportsLt | None = _Unset,
    le: annotated_types.SupportsLe | None = _Unset,
    multiple_of: float | None = _Unset,
    allow_inf_nan: bool | None = _Unset,
    max_digits: int | None = _Unset,
    decimal_places: int | None = _Unset,
    min_length: int | None = _Unset,
    max_length: int | None = _Unset,
    union_mode: Literal['smart', 'left_to_right'] = _Unset,
    fail_fast: bool | None = _Unset,
    **extra: Unpack[_EmptyKwargs],
)

Source from the content-addressed store, hash-verified

923class="cm"># to understand the magic that happens at runtime with the following overloads:
924@overload class="cm"># type hint the return value as `Any` to avoid type checking regressions when using `...`.
925def Field(
926 default: ellipsis, class="cm"># noqa: F821 # TODO: use `_typing_extra.EllipsisType` when we drop Py3.9
927 *,
928 alias: str | None = _Unset,
929 alias_priority: int | None = _Unset,
930 validation_alias: str | AliasPath | AliasChoices | None = _Unset,
931 serialization_alias: str | None = _Unset,
932 title: str | None = _Unset,
933 field_title_generator: Callable[[str, FieldInfo], str] | None = _Unset,
934 description: str | None = _Unset,
935 examples: list[Any] | None = _Unset,
936 exclude: bool | None = _Unset,
937 exclude_if: Callable[[Any], bool] | None = _Unset,
938 discriminator: str | types.Discriminator | None = _Unset,
939 deprecated: Deprecated | str | bool | None = _Unset,
940 json_schema_extra: JsonDict | Callable[[JsonDict], None] | None = _Unset,
941 frozen: bool | None = _Unset,
942 validate_default: bool | None = _Unset,
943 repr: bool = _Unset,
944 init: bool | None = _Unset,
945 init_var: bool | None = _Unset,
946 kw_only: bool | None = _Unset,
947 pattern: str | re.Pattern[str] | None = _Unset,
948 strict: bool | None = _Unset,
949 coerce_numbers_to_str: bool | None = _Unset,
950 gt: annotated_types.SupportsGt | None = _Unset,
951 ge: annotated_types.SupportsGe | None = _Unset,
952 lt: annotated_types.SupportsLt | None = _Unset,
953 le: annotated_types.SupportsLe | None = _Unset,
954 multiple_of: float | None = _Unset,
955 allow_inf_nan: bool | None = _Unset,
956 max_digits: int | None = _Unset,
957 decimal_places: int | None = _Unset,
958 min_length: int | None = _Unset,
959 max_length: int | None = _Unset,
960 union_mode: Literal[&class="cm">#x27;smartclass="st">', 'left_to_right'] = _Unset,
961 fail_fast: bool | None = _Unset,
962 **extra: Unpack[_EmptyKwargs],
963) -> Any: ...
964@overload class="cm"># `default` argument set, validate_default=True (no type checking on the default value)
965def Field(
966 default: Any,

Callers 15

ModelClass · 0.90
FromAttributesModelClass · 0.90
DataTDClass · 0.90
FooClass · 0.90
ModelClass · 0.90
fooFunction · 0.90
FooClass · 0.90
PetClass · 0.90
ModelClass · 0.90

Calls 4

PydanticUserErrorClass · 0.85
keysMethod · 0.80
from_fieldMethod · 0.80
__repr__Method · 0.45

Tested by 15

fooFunction · 0.72
funcFunction · 0.72
test_field_reuseFunction · 0.72
test_annotated_aliasFunction · 0.72
propMethod · 0.72
fooFunction · 0.72