Create a pydantic model with the given field definitions. Args: __model_name: The name of the model. **field_definitions: The field definitions for the model. Returns: Type[BaseModel]: The created model.
(
__model_name: str,
**field_definitions: Any,
)
| 509 | |
| 510 | |
| 511 | def create_model( |
| 512 | __model_name: str, |
| 513 | **field_definitions: Any, |
| 514 | ) -> Type[BaseModel]: |
| 515 | """Create a pydantic model with the given field definitions. |
| 516 | |
| 517 | Args: |
| 518 | __model_name: The name of the model. |
| 519 | **field_definitions: The field definitions for the model. |
| 520 | |
| 521 | Returns: |
| 522 | Type[BaseModel]: The created model. |
| 523 | """ |
| 524 | try: |
| 525 | return _create_model_cached(__model_name, **field_definitions) |
| 526 | except TypeError: |
| 527 | # something in field definitions is not hashable |
| 528 | return _create_model_base( |
| 529 | __model_name, __config__=_SchemaConfig, **field_definitions |
| 530 | ) |
| 531 | |
| 532 | |
| 533 | @lru_cache(maxsize=256) |
no test coverage detected