Skip to content

Commit

Permalink
ruff findings
Browse files Browse the repository at this point in the history
  • Loading branch information
LavermanJJ committed Aug 30, 2023
1 parent ba18850 commit 585af5c
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 9 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
check: check-pylint check-black

check-pylint:
@poetry run pylint pysolarfocus/*
@poetry run pylint --errors-only pysolarfocus/*

check-black:
@poetry run black --check pysolarfocus/*
Expand All @@ -13,4 +13,7 @@ codefix:
test:
@poetry run pytest

.PHONY: check codefix test
run:
@poetry run python3 example.py

.PHONY: check codefix test run
4 changes: 2 additions & 2 deletions example.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pysolarfocus import SolarfocusAPI, Systems, ApiVersions
from pysolarfocus import ApiVersions, SolarfocusAPI, Systems

# Create the Solarfocus API client
solarfocus = SolarfocusAPI(
Expand All @@ -17,7 +17,7 @@
print("\n")
print(solarfocus.buffers[0])
print("\n")
if solarfocus.system is Systems.THERMINATOR:
if solarfocus.system in [Systems.THERMINATOR, Systems.ECOTOP]:
print(solarfocus.biomassboiler)
if solarfocus.system is Systems.VAMPAIR:
print(solarfocus.heatpump)
Expand Down
28 changes: 27 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,31 @@ pymodbus = "3.2.2"
packaging = "^23.1"

[tool.poetry.dev-dependencies]
ruff = "^0.0.286"
black = "^22.10.0"
isort = "^5.10.1"
pylint = "^2.15.9"
pytest = "^5.2.0"


[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.isort]
profile = "black"

[tool.ruff]
# Decrease the maximum line length to 79 characters.
line-length = 180
select = [
"E", # pycodestyle
"F", # pyflakes
"I", # pyupgrade
]

[tool.black]
target-version = ["py39", "py310"]
target-version = ["py311"]
line-length = 180

[tool.pylint.MAIN]
Expand Down
8 changes: 6 additions & 2 deletions pysolarfocus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,19 @@ def update_fresh_water_modules(self) -> bool:

def update_heatpump(self) -> bool:
"""Read values from Heating System"""
return self.heatpump.update()
if self._system is Systems.VAMPAIR:
return self.heatpump.update()
return True

def update_photovoltaic(self) -> bool:
"""Read values from Heating System"""
return self.photovoltaic.update()

def update_biomassboiler(self) -> bool:
"""Read values from biomass boiler"""
return self.biomassboiler.update()
if self._system in [Systems.THERMINATOR, Systems.ECOTOP]:
return self.biomassboiler.update()
return True

def update_solar(self) -> bool:
"""Read values from Solar"""
Expand Down
2 changes: 1 addition & 1 deletion pysolarfocus/components/base/data_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_absolute_address(self) -> int:
Returns the absolute address of the register
"""
if not self.absolut_address:
raise Exception("Absolute address not set!")
raise ValueError("Absolute address not set!")
return self.absolut_address + self.address

@property
Expand Down

0 comments on commit 585af5c

Please sign in to comment.