Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace black and isort with ruff #68

Merged
merged 4 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
name: Lint

on: [push, pull_request]
on: [push]

jobs:
black:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable

isort:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: isort/isort-action@v1
- uses: astral-sh/ruff-action@v3
19 changes: 17 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,20 @@ include-package-data = false
exclude = ["tests"]
namespaces = false

[tool.isort]
profile = "black"
[tool.ruff.lint]
select = [
# pycodestyle
"E",
# Pyflakes
"F",
# pyupgrade
"UP",
# flake8-bugbear
"B",
# isort
"I",]



[tool.ruff.lint.mccabe]
max-complexity = 25
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-r requirements.txt
black
aioresponses==0.7.6
pytest>=6.2.0
pytest-asyncio>=0.15.0
pytest-mock>=3.6.0
aioresponses==0.7.6
ruff
6 changes: 4 additions & 2 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ async def test_auth_will_check_all_client_creds(
expected = []

for i in range(len(client_creds)):
# all but the last one should return 404, as we keep checking until we get a 200 (or run out)
# all but the last one should return 404, as we keep checking until we get a 200
# (or run out)
status = HTTPStatus.NOT_FOUND if i != len(client_creds) else HTTPStatus.OK
expected.append({"status": status})
aioresponses_mock.post(AUTH_URL, status=status)
Expand Down Expand Up @@ -110,7 +111,8 @@ async def test_auth_bad_credentials(
# assert that the proper method and url were used
assert ("POST", URL(AUTH_URL)) in aioresponses_mock.requests

# get the calls for the method/url and assert length - should be the same as the number of client credentials
# get the calls for the method/url and assert length - should be the same as the
# number of client credentials
calls = aioresponses_mock.requests[("POST", URL(AUTH_URL))]
assert len(calls) == len(backend_selector_mock.client_credentials)

Expand Down
42 changes: 21 additions & 21 deletions tests/test_oven.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ async def test_attributes(

await oven.connect()
assert oven.get_online() is True
assert oven.get_door_opened() == False
assert oven.get_control_locked() == False
assert oven.get_sabbath_mode() == False
assert oven.get_door_opened() is False
assert oven.get_control_locked() is False
assert oven.get_sabbath_mode() is False
assert oven.get_display_brightness_percent() == 90
assert oven.get_oven_cavity_exists(Cavity.Upper) == True
assert oven.get_oven_cavity_exists(Cavity.Lower) == False
assert oven.get_light(Cavity.Upper) == False
assert oven.get_meat_probe_status(Cavity.Upper) == False
assert oven.get_oven_cavity_exists(Cavity.Upper) is True
assert oven.get_oven_cavity_exists(Cavity.Lower) is False
assert oven.get_light(Cavity.Upper) is False
assert oven.get_meat_probe_status(Cavity.Upper) is False
assert oven.get_cook_time(Cavity.Upper) == 81
assert oven.get_temp(Cavity.Upper) == 37.7
assert oven.get_target_temp(Cavity.Upper) == 176.6
Expand All @@ -56,14 +56,14 @@ async def test_attributes(

await oven.connect()
assert oven.get_online() is True
assert oven.get_door_opened() == True
assert oven.get_control_locked() == True
assert oven.get_sabbath_mode() == False
assert oven.get_door_opened() is True
assert oven.get_control_locked() is True
assert oven.get_sabbath_mode() is False
assert oven.get_display_brightness_percent() == 70
assert oven.get_oven_cavity_exists(Cavity.Upper) == True
assert oven.get_oven_cavity_exists(Cavity.Lower) == False
assert oven.get_light(Cavity.Upper) == False
assert oven.get_meat_probe_status(Cavity.Upper) == False
assert oven.get_oven_cavity_exists(Cavity.Upper) is True
assert oven.get_oven_cavity_exists(Cavity.Lower) is False
assert oven.get_light(Cavity.Upper) is False
assert oven.get_meat_probe_status(Cavity.Upper) is False
assert oven.get_cook_time(Cavity.Upper) == 0
assert oven.get_temp(Cavity.Upper) == 0.0
assert oven.get_target_temp(Cavity.Upper) == 0.0
Expand All @@ -77,14 +77,14 @@ async def test_attributes(

await oven.connect()
assert oven.get_online() is True
assert oven.get_door_opened() == False
assert oven.get_control_locked() == False
assert oven.get_sabbath_mode() == False
assert oven.get_door_opened() is False
assert oven.get_control_locked() is False
assert oven.get_sabbath_mode() is False
assert oven.get_display_brightness_percent() == 90
assert oven.get_oven_cavity_exists(Cavity.Upper) == True
assert oven.get_oven_cavity_exists(Cavity.Lower) == False
assert oven.get_light(Cavity.Upper) == False
assert oven.get_meat_probe_status(Cavity.Upper) == False
assert oven.get_oven_cavity_exists(Cavity.Upper) is True
assert oven.get_oven_cavity_exists(Cavity.Lower) is False
assert oven.get_light(Cavity.Upper) is False
assert oven.get_meat_probe_status(Cavity.Upper) is False
assert oven.get_cook_time(Cavity.Upper) == 0
assert oven.get_temp(Cavity.Upper) == 0.0
assert oven.get_target_temp(Cavity.Upper) == 0.0
Expand Down
10 changes: 5 additions & 5 deletions whirlpool/backendselector.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
Brand.Whirlpool: [
{
"client_id": "whirlpool_emea_android_v1",
"client_secret": "h-NBGuG7EY74sSvj9TrJeeTpodJBd4T35bAyV0mfa0YnJ0i4MBue8IiS4iFidkve",
"client_secret": "h-NBGuG7EY74sSvj9TrJeeTpodJBd4T35bAyV0mfa0YnJ0i4MBue8IiS4iFidkve", # noqa: E501
},
{
"client_id": "whirlpool_android_v1",
"client_secret": "yH5BcCm4ogWBoyD_NrlE04vmVps2s8T7KaIi4PYrc_fsdphWpG1IwlLSJ-yl7FGV",
"client_secret": "yH5BcCm4ogWBoyD_NrlE04vmVps2s8T7KaIi4PYrc_fsdphWpG1IwlLSJ-yl7FGV", # noqa: E501
},
],
Brand.Maytag: [
{
"client_id": "maytag_android_v1",
"client_secret": "f1XfYji_D9KfZGovyp8PMgRzrFKjhjY26TV0hu3Mt1-tCCNPl9s95z7QLUfB9UgB",
"client_secret": "f1XfYji_D9KfZGovyp8PMgRzrFKjhjY26TV0hu3Mt1-tCCNPl9s95z7QLUfB9UgB", # noqa: E501
}
],
Brand.KitchenAid: [
{
"client_id": "kitchenaid_android_stg",
"client_secret": "Dn-ukFAFoSWOnB9nVm7Y2DDj4Gs9Bocm6aOkhy0mdNGBj5RcoLkRfCXujuxpKrqF2w15sl1tI45JXwK5Zi4saw",
"client_secret": "Dn-ukFAFoSWOnB9nVm7Y2DDj4Gs9Bocm6aOkhy0mdNGBj5RcoLkRfCXujuxpKrqF2w15sl1tI45JXwK5Zi4saw", # noqa: E501
},
{
"client_id": "kitchenaid_android_v1",
"client_secret": "T5j9T4ZAMnC6EMVpPAwZyKsRykXGfKOMDqikPHYpCKEMYjssPtJtuJtMYEc30g56",
"client_secret": "T5j9T4ZAMnC6EMVpPAwZyKsRykXGfKOMDqikPHYpCKEMYjssPtJtuJtMYEc30g56", # noqa: E501
},
],
}
Expand Down
14 changes: 11 additions & 3 deletions whirlpool/eventsocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ def __init__(
self._session = session

def _create_connect_msg(self):
return f"CONNECT\naccept-version:1.1,1.2\nheart-beat:30000,0\nwcloudtoken:{self._auth.get_access_token()}"
return (
"CONNECT\naccept-version:1.1,1.2\nheart-beat:30000,0\nwcloudtoken:"
f"{self._auth.get_access_token()}"
)

def _create_subscribe_msg(self):
id = uuid.uuid4()
Expand Down Expand Up @@ -113,7 +116,11 @@ async def _run(self):

elif msg.data == WS_STATUS_GOING_AWAY:
LOGGER.warning(
f"Received Going Away message: Waiting for {GOING_AWAY_DELAY} seconds"
(
"Received Going Away message: Waiting for %s"
" seconds"
),
GOING_AWAY_DELAY,
)
# Give server some time to come back up.
await asyncio.sleep(GOING_AWAY_DELAY)
Expand Down Expand Up @@ -158,7 +165,8 @@ async def _run(self):
if self._reconnect_tries < 0:
self._reconnect_tries = 0
LOGGER.info(
f"Waiting to reconnect long delay {RECONNECT_LONG_DELAY} seconds"
f"Waiting to reconnect long delay {RECONNECT_LONG_DELAY}"
" seconds"
)

# Give server some time to come back up.
Expand Down
6 changes: 4 additions & 2 deletions whirlpool/oven.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,16 @@ def get_temp(self, cavity: Cavity = Cavity.Upper):
reported_temp = self.get_attribute(
CAVITY_PREFIX_MAP[cavity] + "_" + ATTR_POSTFIX_TEMP
)
# temperatures are returned in 1/10ths of a degree Celsius, e.g. 2600 returned = 260C
# temperatures are returned in 1/10ths of a degree Celsius,
# e.g. 2600 returned = 260C
return None if reported_temp is None else int(reported_temp) / 10

def get_target_temp(self, cavity: Cavity = Cavity.Upper):
reported_temp = self.get_attribute(
CAVITY_PREFIX_MAP[cavity] + "_" + ATTR_POSTFIX_TARGET_TEMP
)
# temperatures are returned in 1/10ths of a degree Celsius, e.g. 2600 returned = 260C
# temperatures are returned in 1/10ths of a degree Celsius,
# e.g. 2600 returned = 260C
return None if reported_temp is None else int(reported_temp) / 10

def get_cavity_state(self, cavity: Cavity = Cavity.Upper):
Expand Down
Loading