Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Upgrade types and add support for instance autocompletion with dataclass_transform (VS Code autocompletion), drop support for Python 3.6 #230

Merged
merged 7 commits into from
Aug 12, 2022
Prev Previous commit
Next Next commit
✨ Add dataclass_transform to metaclasses
  • Loading branch information
tiangolo authored and art049 committed Aug 12, 2022
commit e9f9227cedc7c1b4e218aa319afba9d944b94311
4 changes: 4 additions & 0 deletions odmantic/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from pydantic.tools import parse_obj_as
from pydantic.typing import is_classvar, resolve_annotations
from pydantic.utils import lenient_issubclass
from typing_extensions import dataclass_transform

from odmantic.bson import (
_BSON_SUBSTITUTED_FIELDS,
Expand All @@ -51,6 +52,7 @@
ReferencedDocumentNotFoundError,
)
from odmantic.field import (
Field,
FieldProxy,
ODMBaseField,
ODMEmbedded,
Expand Down Expand Up @@ -372,6 +374,7 @@ def __new__(
return cls


@dataclass_transform(kw_only_default=True, field_specifiers=(Field, ODMFieldInfo))
class ModelMetaclass(BaseModelMetaclass):
@no_type_check
def __new__( # noqa C901
Expand Down Expand Up @@ -433,6 +436,7 @@ def __pos__(cls) -> str:
return cast(str, getattr(cls, "__collection__"))


@dataclass_transform(kw_only_default=True, field_specifiers=(Field, ODMFieldInfo))
class EmbeddedModelMetaclass(BaseModelMetaclass):
@no_type_check
def __new__(
Expand Down