add docs, provide check if Config is a class, ignore dynamic bases for mypy
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import inspect
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
@ -552,12 +553,20 @@ class ModelMetaclass(pydantic.main.ModelMetaclass):
|
||||
:param attrs: class namespace
|
||||
:type attrs: Dict
|
||||
"""
|
||||
DefaultConfig = get_pydantic_base_orm_config()
|
||||
if "Config" in attrs:
|
||||
class Config(attrs["Config"], get_pydantic_base_orm_config()):
|
||||
ProvidedConfig = attrs["Config"]
|
||||
if not inspect.isclass(ProvidedConfig):
|
||||
raise ModelDefinitionError(
|
||||
f"Config provided for class {name} has to be a class."
|
||||
)
|
||||
|
||||
class Config(ProvidedConfig, DefaultConfig): # type: ignore
|
||||
pass
|
||||
|
||||
attrs["Config"] = Config
|
||||
else:
|
||||
attrs["Config"] = get_pydantic_base_orm_config()
|
||||
attrs["Config"] = DefaultConfig
|
||||
|
||||
attrs["__name__"] = name
|
||||
attrs, model_fields = extract_annotations_and_default_vals(attrs)
|
||||
|
||||
Reference in New Issue
Block a user