Skip to content

Commit

Permalink
Merge branch 'dev' into update-version-to-post2
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham3121 authored Apr 1, 2024
2 parents 581f571 + 899a36a commit 34a6a7e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions packages/syft/src/syft/types/syft_metaclass.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# stdlib
from typing import Any
from typing import TypeVar
from typing import final

# third party
Expand All @@ -10,8 +9,6 @@
# relative
from ..serde.serializable import serializable

_T = TypeVar("_T", bound=BaseModel)


class EmptyType(type):
def __repr__(self) -> str:
Expand All @@ -38,10 +35,12 @@ def __new__(
) -> type:
cls = super().__new__(mcs, cls_name, bases, namespace, *args, **kwargs)

for field_info in cls.model_fields.values():
if field_info.annotation is not None and field_info.is_required():
field_info.annotation = field_info.annotation | EmptyType
field_info.default = Empty
if issubclass(cls, BaseModel):
for field_info in cls.model_fields.values():
if field_info.annotation is not None and field_info.is_required():
field_info.annotation = field_info.annotation | EmptyType
field_info.default = Empty

cls.model_rebuild(force=True)

cls.model_rebuild(force=True)
return cls

0 comments on commit 34a6a7e

Please sign in to comment.