Skip to content

Commit

Permalink
Run ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
timmo001 committed Apr 1, 2024
1 parent 0ea2433 commit c45ef69
Show file tree
Hide file tree
Showing 15 changed files with 91 additions and 96 deletions.
6 changes: 3 additions & 3 deletions aiolyric/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(
self._devices_dict: dict = {}
self._locations: List[LyricLocation] = []
self._locations_dict: dict = {}
self._rooms_dict: dict = {}
self._rooms_dict: dict = {}

@property
def client_id(self) -> str:
Expand Down Expand Up @@ -91,12 +91,12 @@ async def get_thermostat_rooms(
)
json = await response.json()
self.logger.debug(json)

priority = LyricPriority(json)

macId = priority.deviceId # device id in the priority payload refers to the mac address of the device
self._rooms_dict[macId]: dict = {}

# add each room to the room dictionary. Rooms contain motion, temp, and humidity averages for all accessories in a room
for room in priority.currentPriority.rooms:
self._rooms_dict[macId][room.id] = room
Expand Down
10 changes: 5 additions & 5 deletions aiolyric/client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""Lyric: Client"""
import async_timeout
import logging

from abc import abstractmethod
from asyncio import CancelledError, TimeoutError, get_event_loop
from aiohttp import ClientError, ClientSession, ClientResponse
import logging

from aiohttp import ClientError, ClientResponse, ClientSession
import async_timeout

from ..exceptions import LyricAuthenticationException, LyricException
from ..objects.base import LyricBase
from ..exceptions import LyricException, LyricAuthenticationException


class LyricClient(LyricBase):
Expand Down
2 changes: 1 addition & 1 deletion aiolyric/objects/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""Lyric: Objects"""
"""Lyric: Objects"""
2 changes: 1 addition & 1 deletion aiolyric/objects/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ class LyricBaseClient(LyricBase):
def __init__(self, client: "AIOGitHubAPIClient", attributes: dict) -> None:
"""Initialise."""
super().__init__(attributes)
self.client = client
self.client = client
9 changes: 4 additions & 5 deletions aiolyric/objects/device.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
Class object for LyricDevice
"""Class object for LyricDevice
Documentation: https://github.com/timmo001/aiolyric
Generated by generator/generator.py - 2020-08-31 14:06:02.854691
Expand Down Expand Up @@ -68,7 +67,7 @@ class SettingsFan(LyricBase):
@property
def fan(self):
return self.atributes.get("fan", {})


class Settings(LyricBase):
@property
Expand All @@ -94,7 +93,7 @@ def fanModes(self):
@property
def fanChangeableValues(self):
return SettingsFan(self.attributes.get("changeableValues", {}))

@property
def fanMode(self):
return fanChangeableValues(self.attributes.get("mode", None))
Expand Down Expand Up @@ -172,7 +171,7 @@ def locationID(self):
@property
def indoorHumidity(self):
return self.attributes.get("indoorHumidity", None)

@property
def displayedOutdoorHumidity(self):
return self.attributes.get("displayedOutdoorHumidity", None)
Expand Down
4 changes: 2 additions & 2 deletions aiolyric/objects/location.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""
Class object for LyricLocation
"""Class object for LyricLocation
Documentation: https://github.com/timmo001/aiolyric
Generated by generator/generator.py - 2020-08-31 13:55:49.220121
"""
from typing import List

from .base import LyricBase, LyricBaseClient
from .device import LyricDevice

Expand Down
3 changes: 1 addition & 2 deletions aiolyric/objects/priority.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
Class object for LyricPriority
"""Class object for LyricPriority
Documentation: https://github.com/timmo001/aiolyric
Generated by generator/generator.py - 2023-07-27 18:30:29.139453
Expand Down
8 changes: 4 additions & 4 deletions generator/generator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import datetime
import json
import re
import os
from datetime import datetime
import re

DATE = datetime.now()

Expand Down Expand Up @@ -63,7 +63,7 @@ def {testname}({fixture}):


def get_input():
with open("generator/input.json", "r") as inputdata:
with open("generator/input.json") as inputdata:
return json.loads(inputdata.read())


Expand Down Expand Up @@ -276,4 +276,4 @@ def add_object():
generateclass("", data, True)


add_object()
add_object()
5 changes: 5 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Setup for tests."""

from typing import Final

RESPONSE_JSON_BASIC: Final[dict] = {"test": "test"}
4 changes: 1 addition & 3 deletions tests/objects/test_device.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""
Generated by generator/generator.py - 2020-08-31 14:06:02.854691
"""Generated by generator/generator.py - 2020-08-31 14:06:02.854691
"""
from aiolyric.objects.device import LyricDevice
from tests.responses.device_fixture import device_fixture_response


def test_device(device_fixture_response):
Expand Down
4 changes: 1 addition & 3 deletions tests/objects/test_location.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""
Generated by generator/generator.py - 2020-08-31 13:55:49.220121
"""Generated by generator/generator.py - 2020-08-31 13:55:49.220121
"""
from aiolyric.objects.location import LyricLocation
from tests.responses.location_fixture import location_fixture_response


def test_location(location_fixture_response):
Expand Down
25 changes: 12 additions & 13 deletions tests/objects/test_priority.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
"""
Generated by generator/generator.py - 2023-07-27 18:30:29.139453
"""Generated by generator/generator.py - 2023-07-27 18:30:29.139453
"""
from aiolyric.objects.priority import LyricPriority
from tests.responses.priority_fixture import priority_fixture_response


def test_priority(priority_fixture_response):
obj = LyricPriority(priority_fixture_response)
assert obj.deviceId == priority_fixture_response['deviceId']
assert obj.status == priority_fixture_response['status']
assert obj.currentPriority.priorityType == priority_fixture_response['currentPriority']['priorityType']
assert obj.currentPriority.selectedRooms[0] == priority_fixture_response['currentPriority']['selectedRooms'][0]
assert obj.currentPriority.rooms[0].id == priority_fixture_response['currentPriority']['rooms'][0]['id']
assert obj.currentPriority.rooms[0].roomName == priority_fixture_response['currentPriority']['rooms'][0]['roomName']
assert obj.currentPriority.rooms[0].roomAvgTemp == priority_fixture_response['currentPriority']['rooms'][0]['roomAvgTemp']
assert obj.currentPriority.rooms[0].roomAvgHumidity == priority_fixture_response['currentPriority']['rooms'][0]['roomAvgHumidity']
assert obj.currentPriority.rooms[0].overallMotion == priority_fixture_response['currentPriority']['rooms'][0]['overallMotion']
assert obj.currentPriority.rooms[0].accessories == priority_fixture_response['currentPriority']['rooms'][0]['accessories']
assert obj.deviceId == priority_fixture_response["deviceId"]
assert obj.status == priority_fixture_response["status"]
assert obj.currentPriority.priorityType == priority_fixture_response["currentPriority"]["priorityType"]
assert obj.currentPriority.selectedRooms[0] == priority_fixture_response["currentPriority"]["selectedRooms"][0]
assert obj.currentPriority.rooms[0].id == priority_fixture_response["currentPriority"]["rooms"][0]["id"]
assert obj.currentPriority.rooms[0].roomName == priority_fixture_response["currentPriority"]["rooms"][0]["roomName"]
assert obj.currentPriority.rooms[0].roomAvgTemp == priority_fixture_response["currentPriority"]["rooms"][0]["roomAvgTemp"]
assert obj.currentPriority.rooms[0].roomAvgHumidity == priority_fixture_response["currentPriority"]["rooms"][0]["roomAvgHumidity"]
assert obj.currentPriority.rooms[0].overallMotion == priority_fixture_response["currentPriority"]["rooms"][0]["overallMotion"]
assert obj.currentPriority.rooms[0].accessories == priority_fixture_response["currentPriority"]["rooms"][0]["accessories"]
3 changes: 1 addition & 2 deletions tests/responses/device_fixture.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
Generated by generator/generator.py - 2020-08-31 14:06:02.854691
"""Generated by generator/generator.py - 2020-08-31 14:06:02.854691
"""
import pytest

Expand Down
3 changes: 1 addition & 2 deletions tests/responses/location_fixture.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
Generated by generator/generator.py - 2020-08-31 13:55:49.220121
"""Generated by generator/generator.py - 2020-08-31 13:55:49.220121
"""
import pytest

Expand Down
99 changes: 49 additions & 50 deletions tests/responses/priority_fixture.py
Original file line number Diff line number Diff line change
@@ -1,71 +1,70 @@
"""
Generated by generator/generator.py - 2023-07-27 18:30:29.139453
"""Generated by generator/generator.py - 2023-07-27 18:30:29.139453
"""
import pytest


@pytest.fixture()
def priority_fixture_response():
return {
'deviceId': '00A01AB1ABCD',
'status': 'NoHold',
'currentPriority': {
'priorityType': 'PickARoom',
'selectedRooms': [
"deviceId": "00A01AB1ABCD",
"status": "NoHold",
"currentPriority": {
"priorityType": "PickARoom",
"selectedRooms": [
0
],
'rooms': [
],
"rooms": [
{
'id': 0,
'roomName': 'Hallway',
'roomAvgTemp': 76,
'roomAvgHumidity': 54,
'overallMotion': False,
'accessories': [
"id": 0,
"roomName": "Hallway",
"roomAvgTemp": 76,
"roomAvgHumidity": 54,
"overallMotion": False,
"accessories": [
{
'id': 0,
'type': 'Thermostat',
'excludeTemp': False,
'excludeMotion': False,
'temperature': 75.828,
'status': 'Ok',
'detectMotion': False
"id": 0,
"type": "Thermostat",
"excludeTemp": False,
"excludeMotion": False,
"temperature": 75.828,
"status": "Ok",
"detectMotion": False
}
]
},
},
{
'id': 1,
'roomName': 'Office',
'roomAvgTemp': 76,
'roomAvgHumidity': 52,
'overallMotion': True,
'accessories': [
"id": 1,
"roomName": "Office",
"roomAvgTemp": 76,
"roomAvgHumidity": 52,
"overallMotion": True,
"accessories": [
{
'id': 1,
'type': 'IndoorAirSensor',
'excludeTemp': False,
'excludeMotion': False,
'temperature': 76,
'status': 'Ok',
'detectMotion': True
"id": 1,
"type": "IndoorAirSensor",
"excludeTemp": False,
"excludeMotion": False,
"temperature": 76,
"status": "Ok",
"detectMotion": True
}
]
},
},
{
'id': 2,
'roomName': 'Master Bedroom',
'roomAvgTemp': 76,
'roomAvgHumidity': 52,
'overallMotion': False,
'accessories': [
"id": 2,
"roomName": "Master Bedroom",
"roomAvgTemp": 76,
"roomAvgHumidity": 52,
"overallMotion": False,
"accessories": [
{
'id': 2,
'type': 'IndoorAirSensor',
'excludeTemp': False,
'excludeMotion': False,
'temperature': 76,
'status': 'Ok',
'detectMotion': True
"id": 2,
"type": "IndoorAirSensor",
"excludeTemp": False,
"excludeMotion": False,
"temperature": 76,
"status": "Ok",
"detectMotion": True
}
]
}
Expand Down

0 comments on commit c45ef69

Please sign in to comment.