Skip to content

Commit

Permalink
chore: rename function
Browse files Browse the repository at this point in the history
  • Loading branch information
timurbazhirov committed Apr 4, 2024
1 parent b86d11d commit 143fd47
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/py/mat3ra/code/entity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, List, Optional, Union
from typing import Any, Dict, List, Optional

import jsonschema
from mat3ra.utils import object as object_utils
Expand Down Expand Up @@ -39,15 +39,15 @@ def cls(self) -> str:
def get_cls_name(self) -> str:
return self.__class__.__name__

@staticmethod
def create(config: Dict[str, Any]) -> "InMemoryEntity":
return InMemoryEntity(config)
@classmethod
def create(cls, config: Dict[str, Any]) -> Any:
return cls(config)

def to_json(self, exclude: List[str] = []) -> Dict[str, Any]:
return self.clean(object_utils.clone_deep(object_utils.omit(self._json, exclude)))

def clone(self, extra_context: Dict[str, Any] = {}) -> "InMemoryEntity":
return self.__class__({**self.to_json(), **extra_context})
def clone(self, extra_context: Dict[str, Any] = {}) -> Any:
return self.__class__.__init__({**self.to_json(), **extra_context})

@staticmethod
def validate_data(data: Dict[str, Any], clean: bool = False):
Expand Down
10 changes: 5 additions & 5 deletions src/py/mat3ra/code/mixins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class DefaultableMixin(BaseUnderscoreJsonPropsHandler):

@property
def is_default(self) -> bool:
return self.prop("isDefault", False)
return self.get_prop("isDefault", False)

@is_default.setter
def is_default(self, is_default: bool = False) -> None:
Expand All @@ -22,7 +22,7 @@ def create_default(cls) -> "DefaultableMixin":
class NamedMixin(BaseUnderscoreJsonPropsHandler):
@property
def name(self) -> str:
return self.prop("name", False)
return self.get_prop("name", False)

@name.setter
def name(self, name: str = "") -> None:
Expand All @@ -32,7 +32,7 @@ def name(self, name: str = "") -> None:
class HasMetadataMixin(BaseUnderscoreJsonPropsHandler):
@property
def metadata(self) -> Dict:
return self.prop("metadata", False)
return self.get_prop("metadata", False)

@metadata.setter
def metadata(self, metadata: Dict = {}) -> None:
Expand All @@ -42,15 +42,15 @@ def metadata(self, metadata: Dict = {}) -> None:
class HasDescriptionMixin(BaseUnderscoreJsonPropsHandler):
@property
def description(self) -> str:
return self.prop("description", "")
return self.get_prop("description", "")

@description.setter
def description(self, description: str = "") -> None:
self.set_prop("description", description)

@property
def description_object(self) -> str:
return self.prop("descriptionObject", "")
return self.get_prop("descriptionObject", "")

@description_object.setter
def description_object(self, description_object: str = "") -> None:
Expand Down

0 comments on commit 143fd47

Please sign in to comment.