Skip to content

Commit

Permalink
Merge pull request #58 from natekspencer/dev
Browse files Browse the repository at this point in the history
Switch to ruff
  • Loading branch information
natekspencer authored Apr 4, 2024
2 parents 29c93c1 + 52ae0c3 commit c5c6db6
Show file tree
Hide file tree
Showing 16 changed files with 220 additions and 652 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
interval: "monthly"
13 changes: 5 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,23 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
- name: Install dependencies
run: poetry install
- name: Run linting
run: |
poetry run isort .
poetry run black . --check
poetry run flake8 .
poetry run pylint pybalboa tests
poetry run pydocstyle pybalboa tests
poetry run ruff check .
poetry run ruff format . --check
- name: Run mypy
run: poetry run mypy pybalboa tests
- name: Test with pytest
Expand Down
799 changes: 173 additions & 626 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pybalboa/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Balboa spa module."""

__version__ = "1.0.1"


Expand Down
5 changes: 3 additions & 2 deletions pybalboa/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Main entry."""

import asyncio
import logging
import sys
Expand Down Expand Up @@ -128,7 +129,7 @@ async def test_controls(spa: SpaClient) -> None:
if option not in (state, control.state):
await adjust_control(control, option)
if control.state != state:
await adjust_control(control, state)
await adjust_control(control, state) # type: ignore
print()


Expand Down Expand Up @@ -161,7 +162,7 @@ async def adjust_control(control: SpaControl, state: IntEnum) -> None:

async def _state_check() -> None:
while control.state != state:
await asyncio.sleep(0.1)
await asyncio.sleep(0.1) # type: ignore

wait = 10
try:
Expand Down
1 change: 1 addition & 0 deletions pybalboa/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Balboa spa client."""

from __future__ import annotations

import asyncio
Expand Down
3 changes: 2 additions & 1 deletion pybalboa/control.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Balboa spa control."""

from __future__ import annotations

import logging
Expand Down Expand Up @@ -187,7 +188,7 @@ async def set_state(self, state: int | HeatMode) -> bool:
return False
if self._state == state:
return True
i = 2 if self.state == HeatMode.READY_IN_REST and state == HeatMode.READY else 1
i = 2 if self.state == HeatMode.READY_IN_REST and state == HeatMode.READY else 1 # type: ignore
for _ in range(i):
await self._client.send_message(MessageType.TOGGLE_STATE, self._code)
return True
Expand Down
1 change: 1 addition & 0 deletions pybalboa/enums.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Enums module."""

from __future__ import annotations

from enum import Enum, IntEnum
Expand Down
1 change: 1 addition & 0 deletions pybalboa/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities module."""

from __future__ import annotations

import asyncio
Expand Down
12 changes: 4 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,16 @@ keywords = ["Balboa", "spa", "hot tub", "asynchronous"]
include = ["pybalboa/py.typed"]

[tool.poetry.dependencies]
python = "^3.7.2"
python = "^3.8.1"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
pytest = "^7.2.2"
pytest-asyncio = "^0.20.3"
pytest-cov = "^4.0.0"
pytest-timeout = "^2.1.0"
black = "^23.1.0"
isort = "^5.11.5"
mypy = "^1.1"
flake8 = "^5.0.4"
pylint = "^2.17.0"
mypy = "^1.3"
tox = "^3.26.0"
pydocstyle = "^6.3.0"
ruff = "^0.3"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Conftest."""

from __future__ import annotations

import asyncio
Expand Down
21 changes: 21 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests module."""

from __future__ import annotations

import pytest
Expand Down Expand Up @@ -31,34 +32,40 @@ async def test_bfbp20s(bfbp20s: SpaServer) -> None:

control = spa.pumps[0]
assert control.name == "Pump 1"
assert isinstance(control.state, OffLowHighState)
assert control.state == OffLowHighState.OFF
assert control.options == list(OffLowHighState)

control = spa.lights[0]
assert control.name == "Light 1"
assert isinstance(control.state, OffOnState)
assert control.state == OffOnState.ON
assert control.options == list(OffOnState)
await control.set_state(OffOnState.OFF)
assert bfbp20s.received_messages[-1]

control = spa.lights[1]
assert control.name == "Light 2"
assert isinstance(control.state, OffOnState)
assert control.state == OffOnState.OFF
assert control.options == list(OffOnState)

assert spa.circulation_pump
control = spa.circulation_pump
assert control.name == "Circulation pump"
assert isinstance(control.state, OffOnState)
assert control.state == OffOnState.ON
assert control.options == list(OffOnState)

control = spa.temperature_range
assert control.name == "Temperature range"
assert isinstance(control.state, LowHighRange)
assert control.state == LowHighRange.HIGH
assert control.options == list(LowHighRange)

control = spa.heat_mode
assert control.name == "Heat mode"
assert isinstance(control.state, HeatMode)
assert control.state == HeatMode.READY
assert control.options == list(HeatMode)[:2]

Expand All @@ -77,11 +84,13 @@ async def test_lpi501st(lpi501st: SpaServer) -> None:

control = spa.pumps[0]
assert control.name == "Pump 1"
assert isinstance(control.state, OffLowHighState)
assert control.state == OffLowHighState.OFF
assert control.options == list(OffLowHighState)

control = spa.pumps[1]
assert control.name == "Pump 2"
assert isinstance(control.state, OffOnState)
assert control.state == OffOnState.OFF
assert control.options == list(OffOnState)

Expand All @@ -98,11 +107,13 @@ async def test_mxbp20(mxbp20: SpaServer) -> None:

control = spa.pumps[0]
assert control.name == "Pump 1"
assert isinstance(control.state, OffLowHighState)
assert control.state == OffLowHighState.OFF
assert control.options == list(OffLowHighState)

control = spa.pumps[1]
assert control.name == "Pump 2"
assert isinstance(control.state, OffLowHighState)
assert control.state == OffLowHighState.OFF
assert control.options == list(OffLowHighState)

Expand All @@ -128,28 +139,33 @@ async def test_bp501g1(bp501g1: SpaServer) -> None:

control = spa.pumps[0]
assert control.name == "Pump 1"
assert isinstance(control.state, OffLowHighState)
assert control.state == OffLowHighState.LOW
assert control.options == list(OffLowHighState)

control = spa.pumps[1]
assert control.name == "Pump 2"
assert isinstance(control.state, OffOnState)
assert control.state == OffOnState.ON
assert control.options == list(OffOnState)

control = spa.lights[0]
assert control.name == "Light 1"
assert isinstance(control.state, OffOnState)
assert control.state == OffOnState.OFF
assert control.options == list(OffOnState)
await control.set_state(OffOnState.ON)
assert bp501g1.received_messages[-1]

control = spa.temperature_range
assert control.name == "Temperature range"
assert isinstance(control.state, LowHighRange)
assert control.state == LowHighRange.HIGH
assert control.options == list(LowHighRange)

control = spa.heat_mode
assert control.name == "Heat mode"
assert isinstance(control.state, HeatMode)
assert control.state == HeatMode.READY
assert control.options == list(HeatMode)[:2]

Expand Down Expand Up @@ -177,29 +193,34 @@ async def test_bp6013g1(bp6013g1: SpaServer) -> None:

control = spa.pumps[0]
assert control.name == "Pump 1"
assert isinstance(control.state, OffOnState)
assert control.state == OffOnState.OFF
assert control.options == list(OffOnState)

control = spa.lights[0]
assert control.name == "Light 1"
assert isinstance(control.state, OffOnState)
assert control.state == OffOnState.ON
assert control.options == list(OffOnState)
await control.set_state(OffOnState.OFF)
assert bp6013g1.received_messages[-1]

control = spa.blowers[0]
assert control.name == "Blower 1"
assert isinstance(control.state, OffOnState)
assert control.state == OffOnState.OFF
assert control.options == list(OffOnState)
await control.set_state(OffOnState.ON)
assert bp6013g1.received_messages[-1]

control = spa.temperature_range
assert control.name == "Temperature range"
assert isinstance(control.state, LowHighRange)
assert control.state == LowHighRange.HIGH
assert control.options == list(LowHighRange)

control = spa.heat_mode
assert control.name == "Heat mode"
assert isinstance(control.state, HeatMode)
assert control.state == HeatMode.READY
assert control.options == list(HeatMode)[:2]
1 change: 1 addition & 0 deletions tests/test_enums.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests module."""

from pybalboa.enums import MessageType, SettingsCode


Expand Down
1 change: 1 addition & 0 deletions tests/test_init.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests module."""

from pybalboa import __version__


Expand Down
1 change: 1 addition & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests module."""

import asyncio

from pybalboa.utils import (
Expand Down
9 changes: 3 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
isolated_build = True
envlist = lint, mypy, py38, py39, py310, py311
envlist = lint, mypy, py39, py310, py311, py312
skip_missing_interpreters = True

[tox:.package]
Expand All @@ -14,11 +14,8 @@ commands =
[testenv:lint]
ignore_errors = True
commands =
poetry run isort .
poetry run black . --check
poetry run flake8 pybalboa tests
poetry run pylint pybalboa tests
poetry run pydocstyle pybalboa tests
poetry run ruff check .
poetry run ruff format . --check

[testenv:mypy]
ignore_errors = True
Expand Down

0 comments on commit c5c6db6

Please sign in to comment.