Skip to content

Commit

Permalink
Fix dataclass transform constructor type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
art049 committed Aug 31, 2022
1 parent 25f2b69 commit dfb304e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions odmantic/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,9 @@ class _BaseODMModel(pydantic.BaseModel, metaclass=ABCMeta):
__mutable_fields__: ClassVar[FrozenSet[str]] = frozenset()
__references__: ClassVar[Tuple[str, ...]] = ()
__pydantic_model__: ClassVar[Type[BaseBSONModel]]
__fields_modified__: Set[str] = set()
# __fields_modified__ is not a ClassVar but this allows to hide this field from
# the dataclass transform generated constructor
__fields_modified__: ClassVar[Set[str]] = set()

__slots__ = ("__fields_modified__",)

Expand Down Expand Up @@ -756,7 +758,7 @@ class Model(_BaseODMModel, metaclass=ModelMetaclass):
__collection__: ClassVar[str] = ""
__primary_field__: ClassVar[str] = ""

id: Union[ObjectId, Any] = None # TODO fix basic id field typing
id: Union[ObjectId, Any] = Field(init=False) # TODO fix basic id field typing

def __setattr__(self, name: str, value: Any) -> None:
if name == self.__primary_field__:
Expand Down

0 comments on commit dfb304e

Please sign in to comment.