Add flake8 config

This commit is contained in:
Andre Basche 2023-07-18 21:31:16 +02:00
parent 4f7d4860db
commit 22367242a2
4 changed files with 10 additions and 5 deletions

3
.flake8 Normal file
View File

@ -0,0 +1,3 @@
[flake8]
max-line-length = 88
max-complexity = 7

View File

@ -28,7 +28,7 @@ jobs:
python -m pip install -r requirements_dev.txt python -m pip install -r requirements_dev.txt
- name: Lint with flake8 - name: Lint with flake8
run: | run: |
flake8 . --count --max-complexity=7 --max-line-length=88 --statistics flake8 . --count --statistics
- name: Type check with mypy - name: Type check with mypy
run: | run: |
mypy pyhon/ mypy pyhon/

View File

@ -28,7 +28,7 @@ class HonCommand:
category_name: str = "", category_name: str = "",
): ):
self._name: str = name self._name: str = name
self._api: Optional[HonAPI] = appliance.api self._api: Optional[HonAPI] = None
self._appliance: "HonAppliance" = appliance self._appliance: "HonAppliance" = appliance
self._categories: Optional[Dict[str, "HonCommand"]] = categories self._categories: Optional[Dict[str, "HonCommand"]] = categories
self._category_name: str = category_name self._category_name: str = category_name
@ -48,6 +48,8 @@ class HonCommand:
@property @property
def api(self) -> "HonAPI": def api(self) -> "HonAPI":
if self._api is None and self._appliance:
self._api = self._appliance.api
if self._api is None: if self._api is None:
raise exceptions.NoAuthenticationException("Missing hOn login") raise exceptions.NoAuthenticationException("Missing hOn login")
return self._api return self._api

View File

@ -16,9 +16,9 @@ class HonParameterRange(HonParameter):
def _set_attributes(self) -> None: def _set_attributes(self) -> None:
super()._set_attributes() super()._set_attributes()
self._min = str_to_float(self._attributes["minimumValue"]) self._min = str_to_float(self._attributes.get("minimumValue", 0))
self._max = str_to_float(self._attributes["maximumValue"]) self._max = str_to_float(self._attributes.get("maximumValue", 0))
self._step = str_to_float(self._attributes["incrementValue"]) self._step = str_to_float(self._attributes.get("incrementValue", 0))
self._default = str_to_float(self._attributes.get("defaultValue", self.min)) self._default = str_to_float(self._attributes.get("defaultValue", self.min))
self._value = self._default self._value = self._default