mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 09:53:32 +01:00
Fix errors reported by mypy
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
bee3e28ff5
commit
7399388f60
2 changed files with 10 additions and 8 deletions
|
|
@ -63,7 +63,7 @@ class Config(): # export
|
|||
return ret
|
||||
|
||||
def __init__(self, search_dirs: Optional[list[str]]=None, glob_paths: Optional[list[str]]=None,
|
||||
defaults: Dict[str, str]=None, tree: Optional[StringTree]=None, parent=None,
|
||||
defaults: Optional[Dict[str, str]]=None, tree: Optional[StringTree]=None, parent=None,
|
||||
root_section=None) -> None:
|
||||
|
||||
self.__parent = parent
|
||||
|
|
@ -77,14 +77,15 @@ class Config(): # export
|
|||
self.__conf = self.__load(search_dirs=search_dirs, glob_paths=glob_paths)
|
||||
|
||||
if root_section is not None:
|
||||
self.__conf = self.__conf.get(root_section)
|
||||
if self.__conf is None:
|
||||
self.__conf = StringTree("", "")
|
||||
tmp = self.__conf.get(root_section)
|
||||
if tmp is None:
|
||||
tmp = StringTree("", "")
|
||||
self.__conf = tmp
|
||||
|
||||
if defaults is not None:
|
||||
for key, val in defaults.items():
|
||||
if self.__conf.get(key) is None:
|
||||
self.__conf.set(key, val)
|
||||
self.__conf[key] = val
|
||||
|
||||
self.__conf.dump(DEBUG, "superposed configuration")
|
||||
|
||||
|
|
@ -108,9 +109,9 @@ class Config(): # export
|
|||
def value(self, key: str, default = None) -> Optional[str]:
|
||||
return self.get(key, default)
|
||||
|
||||
def branch(self, path: str) -> Optional[StringTree]:
|
||||
def branch(self, path: str): # type: ignore # Optional[Config]: FIXME: Don't know how to get hold of this type here
|
||||
if self.__conf:
|
||||
return Config(tree=self.__conf.get(path), parent=self)
|
||||
return Config(tree=self.__conf.get(path), parent=self) # type: ignore
|
||||
return None
|
||||
|
||||
def dump(self, prio: int, *args, **kwargs) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue