Add flake8 lint CI pipeline and fix existing code for compliance.
This commit is contained in:
parent
22d3be4131
commit
1f44cde9a3
|
@ -0,0 +1,14 @@
|
||||||
|
image: "python:3.8"
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- python --version
|
||||||
|
- pip3 install flake8
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- Static Analysis
|
||||||
|
|
||||||
|
flake8:
|
||||||
|
stage: Static Analysis
|
||||||
|
script:
|
||||||
|
- flake8 --max-line-length=120 neohubapi/*.py
|
||||||
|
- flake8 --max-line-length=120 scripts/*.py
|
|
@ -1,4 +1,4 @@
|
||||||
# SPDX-FileCopyrightText: 2020 Andrius Štikonas <andrius@stikonas.eu>
|
# SPDX-FileCopyrightText: 2020 Andrius Štikonas <andrius@stikonas.eu>
|
||||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
|
||||||
from . import neohub
|
from . import neohub # noqa: F401 # flake8 should ignore this.
|
||||||
|
|
|
@ -6,7 +6,7 @@ import asyncio
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
from async_property import async_property, async_cached_property
|
from async_property import async_cached_property
|
||||||
from types import SimpleNamespace
|
from types import SimpleNamespace
|
||||||
|
|
||||||
from neohubapi.enums import ScheduleFormat
|
from neohubapi.enums import ScheduleFormat
|
||||||
|
@ -196,8 +196,10 @@ class NeoHub:
|
||||||
message = {"GET_HOLIDAY": 0}
|
message = {"GET_HOLIDAY": 0}
|
||||||
|
|
||||||
result = await self._send(message)
|
result = await self._send(message)
|
||||||
result.start = datetime.datetime.strptime(result.start.strip(), "%a %b %d %H:%M:%S %Y") if result.start else None
|
result.start = datetime.datetime.strptime(
|
||||||
result.end = datetime.datetime.strptime(result.end.strip(), "%a %b %d %H:%M:%S %Y") if result.end else None
|
result.start.strip(), "%a %b %d %H:%M:%S %Y") if result.start else None
|
||||||
|
result.end = datetime.datetime.strptime(
|
||||||
|
result.end.strip(), "%a %b %d %H:%M:%S %Y") if result.end else None
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def cancel_holiday(self):
|
async def cancel_holiday(self):
|
||||||
|
@ -388,7 +390,7 @@ class NeoHub:
|
||||||
message = {"PERMIT_JOIN": [timeout_s, name]}
|
message = {"PERMIT_JOIN": [timeout_s, name]}
|
||||||
reply = {"result": "network allows joining"}
|
reply = {"result": "network allows joining"}
|
||||||
|
|
||||||
result = await self._send(message)
|
result = await self._send(message, reply)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def set_lock(self, pin: int, devices: [NeoStat]):
|
async def set_lock(self, pin: int, devices: [NeoStat]):
|
||||||
|
|
|
@ -71,7 +71,7 @@ class NeoStat(SimpleNamespace):
|
||||||
for a in self._simple_attrs:
|
for a in self._simple_attrs:
|
||||||
data_attr = a.upper()
|
data_attr = a.upper()
|
||||||
if not hasattr(self._data_, data_attr):
|
if not hasattr(self._data_, data_attr):
|
||||||
self._logger.debug(f"Thermostat object has no attribute {data_attr}")
|
self._logger.debug(f"Thermostat object has no attribute {data_attr}")
|
||||||
self.__dict__[a] = getattr(self._data_, data_attr, None)
|
self.__dict__[a] = getattr(self._data_, data_attr, None)
|
||||||
|
|
||||||
# Renamed attrs
|
# Renamed attrs
|
||||||
|
|
Loading…
Reference in New Issue