PydanticPlugin
The Pydantic mypy plugin.
Attributes
| Attribute | Type | Description |
|---|---|---|
| plugin_config | [PydanticPluginConfig](../v1/mypy/pydanticpluginconfig.md?sid=pydantic_v1_mypy_pydanticpluginconfig) | Configuration object containing Pydantic-specific settings parsed from mypy options. |
| _plugin_data | dict[str, Any] | A dictionary representation of the plugin configuration used by mypy to determine if the cache needs to be discarded. |
Constructor
Signature
def PydanticPlugin(
options: Options
) - > None
Parameters
| Name | Type | Description |
|---|---|---|
| options | Options | The mypy options used to configure the plugin. |
Methods
get_base_class_hook()
@classmethod
def get_base_class_hook(
fullname: str
) - > Callable[[ClassDefContext], None]| None
Update Pydantic model class.
Parameters
| Name | Type | Description |
|---|---|---|
| fullname | str | The fully qualified name of the base class being processed by mypy |
Returns
| Type | Description |
|---|---|
| `Callable[[ClassDefContext], None] | None` |
get_metaclass_hook()
@classmethod
def get_metaclass_hook(
fullname: str
) - > Callable[[ClassDefContext], None]| None
Update Pydantic ModelMetaclass definition.
Parameters
| Name | Type | Description |
|---|---|---|
| fullname | str | The fully qualified name of the metaclass being checked |
Returns
| Type | Description |
|---|---|
| `Callable[[ClassDefContext], None] | None` |
get_method_hook()
@classmethod
def get_method_hook(
fullname: str
) - > Callable[[MethodContext], Type]| None
Adjust return type of from_orm method call.
Parameters
| Name | Type | Description |
|---|---|---|
| fullname | str | The fully qualified name of the method being called |
Returns
| Type | Description |
|---|---|
| `Callable[[MethodContext], Type] | None` |
get_dynamic_class_hook()
@classmethod
def get_dynamic_class_hook(
fullname: str
) - > Callable[[DynamicClassDefContext], None]| None
Recognize create_model() calls as dynamic BaseModel subclasses.
Parameters
| Name | Type | Description |
|---|---|---|
| fullname | str | The fully qualified name of the function creating a dynamic class |
Returns
| Type | Description |
|---|---|
| `Callable[[DynamicClassDefContext], None] | None` |
report_config_data()
@classmethod
def report_config_data(
ctx: ReportConfigContext
) - > dict[str, Any]
Return all plugin config data. Used by mypy to determine if cache needs to be discarded.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | ReportConfigContext | The context provided by mypy for reporting configuration data |
Returns
| Type | Description |
|---|---|
dict[str, Any] | A dictionary containing the current plugin configuration state for cache validation |