Skip to content

Commit

Permalink
format fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
benleb committed Dec 18, 2023
1 parent bf32c45 commit 95386f0
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions surepy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ async def get_token(self) -> str | None:
)

if raw_response.status == HTTPStatus.OK:

response: dict[str, Any] = await raw_response.json()

if "data" in response and "token" in response["data"]:
Expand Down Expand Up @@ -246,7 +245,6 @@ async def call(
)

if response.status == HTTPStatus.OK or response.status == HTTPStatus.CREATED:

self.resources[resource] = response_data = await response.json()

if ETAG in response.headers:
Expand Down Expand Up @@ -335,7 +333,6 @@ async def set_pet_location(self, pet_id: int, location: Location) -> dict[str, A
if (response := await self.call(method="POST", resource=resource, data=data)) and (
response_data := response.get("data")
):

desired_state = data.get("where")
state = response_data.get("where")

Expand Down Expand Up @@ -372,7 +369,6 @@ async def _set_lock_state(self, device_id: int, mode: LockState) -> dict[str, An
method="PUT", resource=resource, device_id=device_id, data=data
)
) and (response_data := response.get("data")):

desired_state = data.get("locking")
state = response_data.get("locking")

Expand Down Expand Up @@ -405,7 +401,6 @@ async def set_curfew(
method="PUT", resource=resource, device_id=device_id, json=data
)
) and (response_data := response.get("data")):

desired_state = data.get("curfew")
state = response_data.get("curfew")

Expand All @@ -418,22 +413,18 @@ async def set_curfew(

async def _add_tag_to_device(self, device_id: int, tag_id: int) -> dict[str, Any] | None:
"""Add the specified tag ID to the specified device ID"""
resource = DEVICE_TAG_RESOURCE.format(BASE_RESOURCE=BASE_RESOURCE, device_id=device_id, tag_id=tag_id)
resource = DEVICE_TAG_RESOURCE.format(
BASE_RESOURCE=BASE_RESOURCE, device_id=device_id, tag_id=tag_id
)

if(
response := await self.call(
method="PUT", resource=resource
)
):
if response := await self.call(method="PUT", resource=resource):
return response

async def _remove_tag_from_device(self, device_id: int, tag_id: int) -> dict[str, Any] | None:
"""Removes the specified tag ID from the specified device ID"""
resource = DEVICE_TAG_RESOURCE.format(BASE_RESOURCE=BASE_RESOURCE, device_id=device_id, tag_id=tag_id)
resource = DEVICE_TAG_RESOURCE.format(
BASE_RESOURCE=BASE_RESOURCE, device_id=device_id, tag_id=tag_id
)

if(
response := await self.call(
method="DELETE", resource=resource
)
):
if response := await self.call(method="DELETE", resource=resource):
return response

0 comments on commit 95386f0

Please sign in to comment.