mirror of https://github.com/Andre0512/pyhOn.git
Add and apply some mypy rules
This commit is contained in:
parent
fc60d15e60
commit
e0774677eb
6
mypy.ini
6
mypy.ini
|
@ -7,3 +7,9 @@ no_implicit_optional = True
|
|||
warn_return_any = True
|
||||
show_error_codes = True
|
||||
warn_unused_ignores = True
|
||||
|
||||
disallow_incomplete_defs = true
|
||||
disallow_subclassing_any = true
|
||||
disallow_untyped_calls = true
|
||||
disallow_untyped_decorators = true
|
||||
warn_unreachable = true
|
|
@ -49,17 +49,20 @@ class HonAppliance:
|
|||
except ModuleNotFoundError:
|
||||
self._extra = None
|
||||
|
||||
def _get_nested_item(self, item: str) -> Any:
|
||||
result: List[Any] | Dict[str, Any] = self.data
|
||||
for key in item.split("."):
|
||||
if all(k in "0123456789" for k in key) and isinstance(result, list):
|
||||
result = result[int(key)]
|
||||
elif isinstance(result, dict):
|
||||
result = result[key]
|
||||
return result
|
||||
|
||||
def __getitem__(self, item: str) -> Any:
|
||||
if self._zone:
|
||||
item += f"Z{self._zone}"
|
||||
if "." in item:
|
||||
result = self.data
|
||||
for key in item.split("."):
|
||||
if all(k in "0123456789" for k in key) and isinstance(result, list):
|
||||
result = result[int(key)]
|
||||
else:
|
||||
result = result[key]
|
||||
return result
|
||||
return self._get_nested_item(item)
|
||||
if item in self.data:
|
||||
return self.data[item]
|
||||
if item in self.attributes["parameters"]:
|
||||
|
|
Loading…
Reference in New Issue