Skip to content

Commit 94bd8c2

Browse files
romintomasettimadebr
authored andcommitted
Refactor CacheEntryProperty to use dataclass
Less code, same behavior.
1 parent 3e06da6 commit 94bd8c2

File tree

1 file changed

+3
-13
lines changed
  • cmake_file_api/kinds/cache

1 file changed

+3
-13
lines changed

cmake_file_api/kinds/cache/v2.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,17 @@ class CacheEntryType(Enum):
1717
TYPE_STATIC = "STATIC"
1818
TYPE_UNINITIALIZED = "UNINITIALIZED"
1919

20-
20+
@dataclasses.dataclass(slots=True, frozen=True, repr=True)
2121
class CacheEntryProperty:
22-
__slots__ = ("name", "value")
23-
24-
def __init__(self, name: str, value: str):
25-
self.name = name
26-
self.value = value
22+
name: str
23+
value: str
2724

2825
@classmethod
2926
def from_dict(cls, dikt: dict[str, Any]) -> "CacheEntryProperty":
3027
name = dikt["name"]
3128
value = dikt["value"]
3229
return cls(name, value)
3330

34-
def __repr__(self) -> str:
35-
return "{}(name='{}', value='{}')".format(
36-
type(self).__name__,
37-
self.name,
38-
self.value,
39-
)
40-
4131
@dataclasses.dataclass(frozen = True, slots = True)
4232
class CacheEntry:
4333
name : str

0 commit comments

Comments
 (0)