Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hramezani committed Oct 31, 2023
1 parent 586d460 commit 218b61b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/concepts/plugins.md
Expand Up @@ -91,7 +91,7 @@ class Plugin(PydanticPluginProtocol):
def new_schema_validator(
self,
schema: CoreSchema,
schema_type: str,
schema_type: Any,
schema_type_path: SchemaTypePath,
schema_kind: Literal[
'BaseModel',
Expand Down
14 changes: 7 additions & 7 deletions pydantic/_internal/_model_construction.py
Expand Up @@ -63,7 +63,7 @@ def __new__(
namespace: dict[str, Any],
__pydantic_generic_metadata__: PydanticGenericMetadata | None = None,
__pydantic_reset_parent_namespace__: bool = True,
cls_module: str | None = None,
_cls_module: str | None = None,
**kwargs: Any,
) -> type:
"""Metaclass for creating Pydantic models.
Expand All @@ -74,7 +74,7 @@ def __new__(
namespace: The attribute dictionary of the class to be created.
__pydantic_generic_metadata__: Metadata for generic models.
__pydantic_reset_parent_namespace__: Reset parent namespace.
cls_module: The module of the class to be created.
_cls_module: The module of the class to be created.
**kwargs: Catch-all for any other keyword arguments.
Returns:
Expand Down Expand Up @@ -184,7 +184,7 @@ def wrapped_model_post_init(self: BaseModel, __context: Any) -> None:
config_wrapper,
raise_errors=False,
types_namespace=types_namespace,
cls_module=cls_module,
_cls_module=_cls_module,
)
# using super(cls, cls) on the next line ensures we only call the parent class's __pydantic_init_subclass__
# I believe the `type: ignore` is only necessary because mypy doesn't realize that this code branch is
Expand Down Expand Up @@ -441,7 +441,7 @@ def complete_model_class(
*,
raise_errors: bool = True,
types_namespace: dict[str, Any] | None,
cls_module: str | None = None,
_cls_module: str | None = None,
) -> bool:
"""Finish building a model class.
Expand All @@ -454,7 +454,7 @@ def complete_model_class(
config_wrapper: The config wrapper instance.
raise_errors: Whether to raise errors.
types_namespace: Optional extra namespace to look for types in.
cls_module: The module of the class to be created.
_cls_module: The module of the class to be created.
Returns:
`True` if the model is successfully completed, else `False`.
Expand Down Expand Up @@ -502,9 +502,9 @@ def complete_model_class(
cls.__pydantic_validator__ = create_schema_validator(
schema,
cls,
cls_module if cls_module else cls.__module__,
_cls_module if _cls_module else cls.__module__,
cls.__qualname__,
'create_model' if cls_module else 'BaseModel',
'create_model' if _cls_module else 'BaseModel',
core_config,
config_wrapper.plugin_settings,
)
Expand Down
4 changes: 2 additions & 2 deletions pydantic/main.py
Expand Up @@ -1434,14 +1434,14 @@ def create_model(
namespace.update(ns)

f = sys._getframe(1)
cls_module = f.f_globals['__name__']
_cls_module = f.f_globals['__name__']

return meta(
__model_name,
resolved_bases,
namespace,
__pydantic_reset_parent_namespace__=False,
cls_module=cls_module,
_cls_module=_cls_module,
**kwds,
)

Expand Down

0 comments on commit 218b61b

Please sign in to comment.