22from configparser import ConfigParser
33from copy import deepcopy
44from pathlib import Path
5- from typing import Dict , List , Optional , Union
5+ from typing import Any , Dict , Union
66
77# external
88from setuptools .config import ConfigMetadataHandler , ConfigOptionsHandler
99
1010# app
1111from ._base import BaseReader
12+ from ._cached_property import cached_property
1213from ._constants import FIELDS
1314
1415
1516class CfgReader (BaseReader ):
1617 def __init__ (self , path : Union [str , Path ]):
1718 self .path = self ._normalize_path (path , default_name = 'setup.cfg' )
1819
19- @property
20- def content (self ) -> Optional [ Dict [str , Union [ List , Dict ]] ]:
20+ @cached_property
21+ def content (self ) -> Dict [str , Any ]:
2122 path = self .path
2223 if path .name == 'setup.py' :
2324 path = path .parent / 'setup.cfg'
@@ -27,7 +28,7 @@ def content(self) -> Optional[Dict[str, Union[List, Dict]]]:
2728 parser = ConfigParser ()
2829 parser .read (str (path ))
2930
30- options = deepcopy (parser ._sections )
31+ options = deepcopy (parser ._sections ) # type: ignore
3132 for section , content in options .items ():
3233 for k , v in content .items ():
3334 options [section ][k ] = ('' , v )
0 commit comments