Add flake8 lint CI pipeline and fix existing code for compliance.

This commit is contained in:
Dave O'Connor 2021-01-23 21:54:55 +00:00 committed by Andrius Štikonas
parent 22d3be4131
commit 1f44cde9a3
4 changed files with 22 additions and 6 deletions

14
.gitlab-ci.yml Normal file
View File

@ -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

View File

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2020 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-License-Identifier: LGPL-3.0-or-later
from . import neohub
from . import neohub # noqa: F401 # flake8 should ignore this.

View File

@ -6,7 +6,7 @@ import asyncio
import datetime
import json
import logging
from async_property import async_property, async_cached_property
from async_property import async_cached_property
from types import SimpleNamespace
from neohubapi.enums import ScheduleFormat
@ -196,8 +196,10 @@ class NeoHub:
message = {"GET_HOLIDAY": 0}
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.end = datetime.datetime.strptime(result.end.strip(), "%a %b %d %H:%M:%S %Y") if result.end else None
result.start = datetime.datetime.strptime(
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
async def cancel_holiday(self):
@ -388,7 +390,7 @@ class NeoHub:
message = {"PERMIT_JOIN": [timeout_s, name]}
reply = {"result": "network allows joining"}
result = await self._send(message)
result = await self._send(message, reply)
return result
async def set_lock(self, pin: int, devices: [NeoStat]):

View File

@ -71,7 +71,7 @@ class NeoStat(SimpleNamespace):
for a in self._simple_attrs:
data_attr = a.upper()
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)
# Renamed attrs