File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ # Feature Enhancement for Issue #5000
2+ from typing import Dict , List , Optional
3+ from dataclasses import dataclass
4+
5+ @dataclass
6+ class ConfigManager :
7+ config : Dict [str , any ] = None
8+
9+ def __post_init__ (self ):
10+ if self .config is None :
11+ self .config = {}
12+
13+ def get (self , key : str , default : Optional [any ] = None ) -> any :
14+ return self .config .get (key , default )
15+
16+ def set (self , key : str , value : any ) -> None :
17+ self .config [key ] = value
18+
19+ def save (self ) -> Dict [str , any ]:
20+ return self .config .copy ()
21+
22+ # 测试
23+ config = ConfigManager ()
24+ config .set ("test" , "value" )
25+ assert config .get ("test" ) == "value"
26+ assert config .save ()["test" ] == "value"
27+ print ("Feature enhancement tests passed!" )
You can’t perform that action at this time.
0 commit comments