Create a new `FieldInfo` object with the `Field` function. Args: default: The default value for the field. Defaults to Undefined. **kwargs: Additional arguments dictionary. Raises: TypeError: If 'annotation' is passed as a keyword argument.
(default: Any = PydanticUndefined, **kwargs: Unpack[_FromFieldInfoInputs])
| 289 | |
| 290 | @staticmethod |
| 291 | def from_field(default: Any = PydanticUndefined, **kwargs: Unpack[_FromFieldInfoInputs]) -> FieldInfo: |
| 292 | """Create a new `FieldInfo` object with the `Field` function. |
| 293 | |
| 294 | Args: |
| 295 | default: The default value for the field. Defaults to Undefined. |
| 296 | **kwargs: Additional arguments dictionary. |
| 297 | |
| 298 | Raises: |
| 299 | TypeError: If 'annotation' is passed as a keyword argument. |
| 300 | |
| 301 | Returns: |
| 302 | A new FieldInfo object with the given parameters. |
| 303 | |
| 304 | Example: |
| 305 | This is how you can create a field with default value like this: |
| 306 | |
| 307 | ```python |
| 308 | import pydantic |
| 309 | |
| 310 | class MyModel(pydantic.BaseModel): |
| 311 | foo: int = pydantic.Field(4) |
| 312 | ``` |
| 313 | """ |
| 314 | if 'annotation' in kwargs: |
| 315 | raise TypeError('"annotation" is not permitted as a Field keyword argument') |
| 316 | return FieldInfo(default=default, **kwargs) |
| 317 | |
| 318 | @staticmethod |
| 319 | def from_annotation(annotation: type[Any], *, _source: AnnotationSource = AnnotationSource.ANY) -> FieldInfo: |