Skip to content

Commit

Permalink
refactor: Catch up to some more HASS PyLint standards
Browse files Browse the repository at this point in the history
  • Loading branch information
jcgoette committed Jan 13, 2023
1 parent 1169809 commit 9284db0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
6 changes: 3 additions & 3 deletions custom_components/babybuddy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import annotations

import logging
from asyncio import TimeoutError
from asyncio import TimeoutError as AsyncIOTimeoutError
from datetime import timedelta
from http import HTTPStatus
from typing import Any
Expand Down Expand Up @@ -193,7 +193,7 @@ async def async_update(
except ClientResponseError as err:
if err.status == HTTPStatus.FORBIDDEN:
raise ConfigEntryAuthFailed from err
except (TimeoutError, ClientError) as err:
except (AsyncIOTimeoutError, ClientError) as err:
raise UpdateFailed(err) from err

if children_list[ATTR_COUNT] < len(self.child_ids):
Expand All @@ -217,7 +217,7 @@ async def async_update(
f"No {endpoint} found for {child[ATTR_FIRST_NAME]} {child[ATTR_LAST_NAME]}. Skipping"
)
continue
except (TimeoutError, ClientError) as err:
except (AsyncIOTimeoutError, ClientError) as err:
_LOGGER.error(err)
continue
data: list[dict[str, str]] = endpoint_data[ATTR_RESULTS]
Expand Down
8 changes: 4 additions & 4 deletions custom_components/babybuddy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import annotations

import logging
from asyncio import TimeoutError
from asyncio import TimeoutError as AsyncIOTimeoutError
from datetime import datetime, time
from http import HTTPStatus
from typing import Any
Expand Down Expand Up @@ -67,7 +67,7 @@ async def async_post(
headers=self.headers,
data=data,
)
except (TimeoutError, ClientError) as err:
except (AsyncIOTimeoutError, ClientError) as err:
_LOGGER.error(err)

if resp.status != HTTPStatus.CREATED:
Expand Down Expand Up @@ -95,7 +95,7 @@ async def async_patch(
headers=self.headers,
data=data,
)
except (TimeoutError, ClientError) as err:
except (AsyncIOTimeoutError, ClientError) as err:
_LOGGER.error(err)

if resp.status != HTTPStatus.OK:
Expand All @@ -110,7 +110,7 @@ async def async_delete(self, endpoint: str, entry: str) -> None:
f"{self.endpoints[endpoint]}{entry}/",
headers=self.headers,
)
except (TimeoutError, ClientError) as err:
except (AsyncIOTimeoutError, ClientError) as err:
_LOGGER.error(err)

if resp.status != 204:
Expand Down
31 changes: 21 additions & 10 deletions custom_components/babybuddy/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ def __init__(self, coordinator: BabyBuddyCoordinator, child: dict) -> None:
}

async def async_add_bmi(
self, bmi: float, date: date | None = None, notes: str | None = None
self,
bmi: float,
date: date | None = None, # pylint: disable=redefined-outer-name
notes: str | None = None,
) -> None:
"""Add BMI entry."""
if not isinstance(self, BabyBuddyChildSensor):
Expand All @@ -228,8 +231,8 @@ async def async_add_bmi(

async def async_add_diaper_change(
self,
type: str | None = None,
time: datetime | time | None = None,
type: str | None = None, # pylint: disable=redefined-builtin
time: datetime | time | None = None, # pylint: disable=redefined-outer-name
color: str | None = None,
amount: int | None = None,
notes: str | None = None,
Expand Down Expand Up @@ -265,7 +268,7 @@ async def async_add_diaper_change(
async def async_add_head_circumference(
self,
head_circumference: float,
date: date | None = None,
date: date | None = None, # pylint: disable=redefined-outer-name
notes: str | None = None,
) -> None:
"""Add head circumference entry."""
Expand All @@ -288,7 +291,10 @@ async def async_add_head_circumference(
await self.coordinator.async_request_refresh()

async def async_add_height(
self, height: float, date: date | None = None, notes: str | None = None
self,
height: float,
date: date | None = None, # pylint: disable=redefined-outer-name
notes: str | None = None,
) -> None:
"""Add height entry."""
if not isinstance(self, BabyBuddyChildSensor):
Expand All @@ -308,7 +314,9 @@ async def async_add_height(
await self.coordinator.async_request_refresh()

async def async_add_note(
self, note: str, time: datetime | time | None = None
self,
note: str,
time: datetime | time | None = None, # pylint: disable=redefined-outer-name
) -> None:
"""Add note entry."""
if not isinstance(self, BabyBuddyChildSensor):
Expand All @@ -330,7 +338,7 @@ async def async_add_note(
async def async_add_pumping(
self,
amount: float,
time: datetime | time | None = None,
time: datetime | time | None = None, # pylint: disable=redefined-outer-name
notes: str | None = None,
) -> None:
"""Add a pumping entry."""
Expand Down Expand Up @@ -358,7 +366,7 @@ async def async_add_pumping(
async def async_add_temperature(
self,
temperature: float,
time: datetime | time | None = None,
time: datetime | time | None = None, # pylint: disable=redefined-outer-name
notes: str | None = None,
) -> None:
"""Add a temperature entry."""
Expand All @@ -384,7 +392,10 @@ async def async_add_temperature(
await self.coordinator.async_request_refresh()

async def async_add_weight(
self, weight: float, date: date | None = None, notes: str | None = None
self,
weight: float,
date: date | None = None, # pylint: disable=redefined-outer-name
notes: str | None = None,
) -> None:
"""Add weight entry."""
if not isinstance(self, BabyBuddyChildSensor):
Expand Down Expand Up @@ -466,7 +477,7 @@ def __init__(
@property
def name(self) -> str:
"""Return the name of the babybuddy sensor."""
type = self.entity_description.key
type = self.entity_description.key # pylint: disable=redefined-builtin
if type[-1] == "s":
type = type[:-1]
return f"{self.child[ATTR_FIRST_NAME]} {self.child[ATTR_LAST_NAME]} last {type}"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/babybuddy/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ async def async_start_timer(

async def async_add_feeding(
self,
type: str,
type: str, # pylint: disable=redefined-builtin
method: str,
timer: bool,
start: datetime | time | None = None,
Expand Down

0 comments on commit 9284db0

Please sign in to comment.