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
|
return ret
|
||||||
|
|
||||||
def __init__(self, search_dirs: Optional[list[str]]=None, glob_paths: Optional[list[str]]=None,
|
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:
|
root_section=None) -> None:
|
||||||
|
|
||||||
self.__parent = parent
|
self.__parent = parent
|
||||||
|
|
@ -77,14 +77,15 @@ class Config(): # export
|
||||||
self.__conf = self.__load(search_dirs=search_dirs, glob_paths=glob_paths)
|
self.__conf = self.__load(search_dirs=search_dirs, glob_paths=glob_paths)
|
||||||
|
|
||||||
if root_section is not None:
|
if root_section is not None:
|
||||||
self.__conf = self.__conf.get(root_section)
|
tmp = self.__conf.get(root_section)
|
||||||
if self.__conf is None:
|
if tmp is None:
|
||||||
self.__conf = StringTree("", "")
|
tmp = StringTree("", "")
|
||||||
|
self.__conf = tmp
|
||||||
|
|
||||||
if defaults is not None:
|
if defaults is not None:
|
||||||
for key, val in defaults.items():
|
for key, val in defaults.items():
|
||||||
if self.__conf.get(key) is None:
|
if self.__conf.get(key) is None:
|
||||||
self.__conf.set(key, val)
|
self.__conf[key] = val
|
||||||
|
|
||||||
self.__conf.dump(DEBUG, "superposed configuration")
|
self.__conf.dump(DEBUG, "superposed configuration")
|
||||||
|
|
||||||
|
|
@ -108,9 +109,9 @@ class Config(): # export
|
||||||
def value(self, key: str, default = None) -> Optional[str]:
|
def value(self, key: str, default = None) -> Optional[str]:
|
||||||
return self.get(key, default)
|
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:
|
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
|
return None
|
||||||
|
|
||||||
def dump(self, prio: int, *args, **kwargs) -> None:
|
def dump(self, prio: int, *args, **kwargs) -> None:
|
||||||
|
|
|
||||||
|
|
@ -93,9 +93,10 @@ def prio_gets_logged(prio: int) -> bool: # export
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def log_level(s: str=None) -> int: # export
|
def log_level(s: Optional[str]=None) -> int: # export
|
||||||
if s is None:
|
if s is None:
|
||||||
return _level
|
return _level
|
||||||
|
return parse_log_prio_str(s)
|
||||||
|
|
||||||
def get_caller_pos(up: int = 1, kwargs: Optional[dict[str, Any]] = None) -> Tuple[str, int]:
|
def get_caller_pos(up: int = 1, kwargs: Optional[dict[str, Any]] = None) -> Tuple[str, int]:
|
||||||
if kwargs and 'caller' in kwargs:
|
if kwargs and 'caller' in kwargs:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue