Skip to content

Commit

Permalink
build: add pylint workflow (#349)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukas Wöhrl <[email protected]>
  • Loading branch information
CFenner and woehrl01 authored Dec 27, 2023
1 parent f69604d commit 63f9f7f
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 14 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ on:
- master

jobs:
pylint:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.9"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Analysing the code with pylint
run: pylint $(git ls-files '*.py')

build:
runs-on: ubuntu-20.04
strategy:
Expand Down
36 changes: 36 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[MAIN]

[MESSAGES CONTROL]
disable=
duplicate-code,
fixme,
format,
invalid-name,
too-many-public-methods,
too-few-public-methods,
# fix later
arguments-differ,
attribute-defined-outside-init,
bad-classmethod-argument,
chained-comparison,
consider-merging-isinstance,
consider-using-dict-items,
consider-using-generator,
consider-using-in,
deprecated-decorator,
f-string-without-interpolation,
logging-fstring-interpolation,
logging-not-lazy,
missing-class-docstring,
missing-function-docstring,
missing-module-docstring,
missing-timeout,
no-else-raise,
no-else-return,
pointless-string-statement,
raise-missing-from,
super-init-not-called,
too-many-boolean-expressions,
unspecified-encoding,
useless-object-inheritance,
useless-parent-delegation,
3 changes: 1 addition & 2 deletions PyViCare/PyViCareDeviceConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ def asAutoDetectDevice(self):

for (creator_method, type_name, roles) in device_types:
if re.search(type_name, self.device_model) or self.service.hasRoles(roles):
logger.info("detected %s %s" %
(self.device_model, creator_method.__name__))
logger.info(f"detected {self.device_model} {creator_method.__name__}")
return creator_method()

logger.info(
Expand Down
1 change: 0 additions & 1 deletion PyViCare/PyViCareElectricalEnergySystem.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import Any, List
from PyViCare.PyViCareDevice import Device
from PyViCare.PyViCareUtils import handleNotSupported
from PyViCare.PyViCareService import ViCareService
Expand Down
10 changes: 5 additions & 5 deletions PyViCare/PyViCareHeatingDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
VICARE_DHW_TEMP2 = "temp-2"


def all_set(list: List[Any]) -> bool:
return all(v is not None for v in list)
def all_set(_list: List[Any]) -> bool:
return all(v is not None for v in _list)


def get_available_burners(service):
Expand Down Expand Up @@ -605,9 +605,9 @@ def getActiveProgram(self):
@handleNotSupported
def getPrograms(self):
available_programs = []
for program in ['comfort', 'comfortCooling', 'comfortCoolingEnergySaving', 'comfortEnergySaving',
'comfortHeating', 'dhwPrecedence', 'eco', 'external', 'fixed', 'forcedLastFromSchedule',
'frostprotection', 'holiday', 'holidayAtHome', 'manual', 'normal', 'normalCooling',
for program in ['comfort', 'comfortCooling', 'comfortCoolingEnergySaving', 'comfortEnergySaving',
'comfortHeating', 'dhwPrecedence', 'eco', 'external', 'fixed', 'forcedLastFromSchedule',
'frostprotection', 'holiday', 'holidayAtHome', 'manual', 'normal', 'normalCooling',
'normalCoolingEnergySaving', 'normalEnergySaving', 'normalHeating', 'reduced', 'reducedCooling',
'reducedCoolingEnergySaving', 'reducedEnergySaving', 'reducedHeating', 'standby', 'summerEco']:
with suppress(PyViCareNotSupportedFeatureError):
Expand Down
2 changes: 1 addition & 1 deletion PyViCare/PyViCareOAuthManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def __serialize_token(self, oauth, token_file):
with open(token_file, mode='wb') as binary_file:
pickle.dump(oauth, binary_file)

logger.info("Token serialized to %s" % token_file)
logger.info(f"Token serialized to {token_file}")

def __deserialize_token(self, token_file):
if token_file is None or not os.path.isfile(token_file):
Expand Down
4 changes: 2 additions & 2 deletions PyViCare/PyViCareService.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def buildSetPropertyUrl(accessor, property_name, action):


class ViCareDeviceAccessor:
def __init__(self, id: int, serial: str, device_id: str) -> None:
self.id = id
def __init__(self, _id: int, serial: str, device_id: str) -> None:
self.id = _id
self.serial = serial
self.device_id = device_id

Expand Down
2 changes: 1 addition & 1 deletion PyViCare/PyViCareVentilationDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def getActiveProgram(self):
json representation of the answer
"""
def activateProgram(self, program):
return self.service.setProperty("ventilation.operating.programs.{program}", "activate", {})
return self.service.setProperty(f"ventilation.operating.programs.{program}", "activate", {})

""" Deactivate a program
Parameters
Expand Down
1 change: 0 additions & 1 deletion tests/test_VitoairFs300E.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import unittest

from PyViCare.PyViCareUtils import PyViCareNotSupportedFeatureError
from PyViCare.PyViCareVentilationDevice import VentilationDevice
from tests.ViCareServiceMock import ViCareServiceMock

Expand Down
2 changes: 1 addition & 1 deletion tests/test_Vitocal200.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_getActiveProgramMinTemperature(self):
def test_getActiveProgramMaxTemperature(self):
self.assertEqual(self.device.getCircuit(0).getActiveProgramMaxTemperature(), 30)

def test_getActiveProgramMaxTemperature(self):
def test_getActiveProgramStepping(self):
self.assertEqual(self.device.getCircuit(0).getActiveProgramStepping(), 1)

def test_getNormalProgramMinTemperature(self):
Expand Down

0 comments on commit 63f9f7f

Please sign in to comment.