diff --git a/mypy.ini b/mypy.ini index 9a76b78..0617b6b 100644 --- a/mypy.ini +++ b/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 \ No newline at end of file diff --git a/pyhon/appliance.py b/pyhon/appliance.py index 2b0959c..8956fc2 100644 --- a/pyhon/appliance.py +++ b/pyhon/appliance.py @@ -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"]: