2
2
from configparser import ConfigParser
3
3
from copy import deepcopy
4
4
from pathlib import Path
5
- from typing import Dict , List , Optional , Union
5
+ from typing import Any , Dict , Union
6
6
7
7
# external
8
8
from setuptools .config import ConfigMetadataHandler , ConfigOptionsHandler
9
9
10
10
# app
11
11
from ._base import BaseReader
12
+ from ._cached_property import cached_property
12
13
from ._constants import FIELDS
13
14
14
15
15
16
class CfgReader (BaseReader ):
16
17
def __init__ (self , path : Union [str , Path ]):
17
18
self .path = self ._normalize_path (path , default_name = 'setup.cfg' )
18
19
19
- @property
20
- def content (self ) -> Optional [ Dict [str , Union [ List , Dict ]] ]:
20
+ @cached_property
21
+ def content (self ) -> Dict [str , Any ]:
21
22
path = self .path
22
23
if path .name == 'setup.py' :
23
24
path = path .parent / 'setup.cfg'
@@ -27,7 +28,7 @@ def content(self) -> Optional[Dict[str, Union[List, Dict]]]:
27
28
parser = ConfigParser ()
28
29
parser .read (str (path ))
29
30
30
- options = deepcopy (parser ._sections )
31
+ options = deepcopy (parser ._sections ) # type: ignore
31
32
for section , content in options .items ():
32
33
for k , v in content .items ():
33
34
options [section ][k ] = ('' , v )
0 commit comments