Skip to content

Commit aedb971

Browse files
committed
Change Gateway.id and Place.id from mutable copies to read-only properties
1 parent 8e73c9f commit aedb971

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pyoverkiz/models.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,6 @@ class Gateway:
735735
sub_type: GatewaySubType | None = field(
736736
default=None, converter=_to_optional_enum(GatewaySubType)
737737
)
738-
id: str = field(repr=obfuscate_id, init=False)
739738
alive: bool | None = None
740739
mode: str | None = None
741740
place_oid: str | None = None
@@ -749,9 +748,10 @@ class Gateway:
749748
default=None, converter=_to_optional_enum(GatewayType)
750749
)
751750

752-
def __attrs_post_init__(self) -> None:
753-
"""Set id from gateway_id."""
754-
self.id = self.gateway_id
751+
@property
752+
def id(self) -> str:
753+
"""Alias for gateway_id."""
754+
return self.gateway_id
755755

756756

757757
@_flexible_init
@@ -808,11 +808,11 @@ class Place:
808808
type: int
809809
oid: str
810810
sub_places: list[Place] = field(factory=list, converter=_to_list("Place"))
811-
id: str = field(init=False)
812811

813-
def __attrs_post_init__(self) -> None:
814-
"""Set id from oid."""
815-
self.id = self.oid
812+
@property
813+
def id(self) -> str:
814+
"""Alias for oid."""
815+
return self.oid
816816

817817

818818
@define(kw_only=True)

0 commit comments

Comments
 (0)