Commit 438f952 1 parent e35445b commit 438f952 Copy full SHA for 438f952
File tree 1 file changed +29
-1
lines changed
1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change
1
+ from datetime import datetime
1
2
from pathlib import Path
2
3
from tomllib import loads
4
+ from typing import TypedDict
3
5
4
6
__all__ = ["nameless_config" ]
5
7
8
+
9
+ class NamelessMetadata (TypedDict ):
10
+ version : str
11
+ description : str
12
+ support_server : str
13
+ start_time : datetime
14
+ is_shutting_down : bool
15
+
16
+
17
+ class NamelessCommands (TypedDict ):
18
+ prefixes : list [str ]
19
+
20
+
21
+ class NamelessBlacklist (TypedDict ):
22
+ users : list [int ]
23
+ guilds : list [int ]
24
+
25
+
26
+ class NamelessConfig (TypedDict ):
27
+ nameless : NamelessMetadata
28
+ command : NamelessCommands
29
+ blacklist : NamelessBlacklist
30
+
31
+
6
32
_cfg_path : Path = Path (__file__ ).parent .parent .absolute () / "nameless.toml"
7
33
8
34
with open (_cfg_path , encoding = "utf-8" ) as f :
9
35
_content : str = f .read ()
10
36
11
- nameless_config = loads (_content )
37
+ # Maybe add a type checker here, using the annotation from the TypedDict
38
+ raw_config = loads (_content )
39
+ nameless_config : NamelessConfig = NamelessConfig (** raw_config ) # pyright: ignore[reportAny]
You can’t perform that action at this time.
0 commit comments