1- from enum import Enum
1+ import dataclasses
2+ from enum import StrEnum
23import json
34from pathlib import Path
45from typing import Any
78from cmake_file_api .kinds .kind import ObjectKind
89
910
10- class CacheEntryType (Enum ):
11+ class CacheEntryType (StrEnum ):
1112 TYPE_BOOL = "BOOL"
1213 TYPE_FILEPATH = "FILEPATH"
1314 TYPE_PATH = "PATH"
@@ -37,15 +38,12 @@ def __repr__(self) -> str:
3738 self .value ,
3839 )
3940
40-
41+ @ dataclasses . dataclass ( frozen = True , slots = True )
4142class CacheEntry :
42- __slots__ = ("name" , "value" , "type" , "properties" )
43-
44- def __init__ (self , name : str , value : str , type : CacheEntryType , properties : list [CacheEntryProperty ]):
45- self .name = name
46- self .value = value
47- self .type = type
48- self .properties = properties
43+ name : str
44+ value : str
45+ type : CacheEntryType
46+ properties : list [CacheEntryProperty ]
4947
5048 @classmethod
5149 def from_dict (cls , dikt : dict [str , Any ]) -> "CacheEntry" :
@@ -55,16 +53,6 @@ def from_dict(cls, dikt: dict[str, Any]) -> "CacheEntry":
5553 properties = list (CacheEntryProperty .from_dict (cep ) for cep in dikt ["properties" ])
5654 return cls (name , value , type , properties )
5755
58- def __repr__ (self ) -> str :
59- return "{}(name='{}', value='{}', type={}, properties={})" .format (
60- type (self ).__name__ ,
61- self .name ,
62- self .value ,
63- self .type .name ,
64- repr (self .properties ),
65- )
66-
67-
6856class CacheV2 :
6957 KIND = ObjectKind .CACHE
7058
0 commit comments