From 22367242a22e62370e76e7c3f7e54f81e9dbdd4b Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Tue, 18 Jul 2023 21:31:16 +0200 Subject: [PATCH] Add flake8 config --- .flake8 | 3 +++ .github/workflows/python-check.yml | 2 +- pyhon/commands.py | 4 +++- pyhon/parameter/range.py | 6 +++--- 4 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 .flake8 diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..3127c2b --- /dev/null +++ b/.flake8 @@ -0,0 +1,3 @@ +[flake8] +max-line-length = 88 +max-complexity = 7 \ No newline at end of file diff --git a/.github/workflows/python-check.yml b/.github/workflows/python-check.yml index a0e7113..3d6f17c 100644 --- a/.github/workflows/python-check.yml +++ b/.github/workflows/python-check.yml @@ -28,7 +28,7 @@ jobs: python -m pip install -r requirements_dev.txt - name: Lint with flake8 run: | - flake8 . --count --max-complexity=7 --max-line-length=88 --statistics + flake8 . --count --statistics - name: Type check with mypy run: | mypy pyhon/ diff --git a/pyhon/commands.py b/pyhon/commands.py index 80fcb93..b671e55 100644 --- a/pyhon/commands.py +++ b/pyhon/commands.py @@ -28,7 +28,7 @@ class HonCommand: category_name: str = "", ): self._name: str = name - self._api: Optional[HonAPI] = appliance.api + self._api: Optional[HonAPI] = None self._appliance: "HonAppliance" = appliance self._categories: Optional[Dict[str, "HonCommand"]] = categories self._category_name: str = category_name @@ -48,6 +48,8 @@ class HonCommand: @property def api(self) -> "HonAPI": + if self._api is None and self._appliance: + self._api = self._appliance.api if self._api is None: raise exceptions.NoAuthenticationException("Missing hOn login") return self._api diff --git a/pyhon/parameter/range.py b/pyhon/parameter/range.py index 6d8f9e9..6eef53e 100644 --- a/pyhon/parameter/range.py +++ b/pyhon/parameter/range.py @@ -16,9 +16,9 @@ class HonParameterRange(HonParameter): def _set_attributes(self) -> None: super()._set_attributes() - self._min = str_to_float(self._attributes["minimumValue"]) - self._max = str_to_float(self._attributes["maximumValue"]) - self._step = str_to_float(self._attributes["incrementValue"]) + self._min = str_to_float(self._attributes.get("minimumValue", 0)) + self._max = str_to_float(self._attributes.get("maximumValue", 0)) + self._step = str_to_float(self._attributes.get("incrementValue", 0)) self._default = str_to_float(self._attributes.get("defaultValue", self.min)) self._value = self._default