Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 29, 2024
1 parent 57242ec commit 027cfe7
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 24 deletions.
1 change: 1 addition & 0 deletions custom_components/nyc311/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The NYC 311 Public Services Calendar integration."""

from __future__ import annotations

from datetime import timedelta
Expand Down
21 changes: 9 additions & 12 deletions custom_components/nyc311/base_device.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base for NYC311 entities."""

from __future__ import annotations

from homeassistant.core import callback
Expand Down Expand Up @@ -35,9 +36,7 @@ def __init__(

def _get_icon(self, active_exception: bool) -> str:
"""Get icon for a given service / state."""
return (
f"{SERVICE_ICONS[self._calendar_entry.service_profile.service_type]}{'' if active_exception else '-off'}"
)
return f"{SERVICE_ICONS[self._calendar_entry.service_profile.service_type]}{'' if active_exception else '-off'}"

async def async_added_to_hass(self) -> None:
"""Register callbacks."""
Expand All @@ -52,15 +51,13 @@ def _handle_coordinator_update(self) -> None:

reason = self._calendar_entry.exception_reason

self._attr_extra_state_attributes.update(
{
"reason": reason if reason else None,
"description": self._calendar_entry.status_profile.description,
"status": self._calendar_entry.status_profile.standardized_type.name.title().replace(
"_", " "
),
}
)
self._attr_extra_state_attributes.update({
"reason": reason if reason else None,
"description": self._calendar_entry.status_profile.description,
"status": self._calendar_entry.status_profile.standardized_type.name.title().replace(
"_", " "
),
})

# If we use dict() here instead of a comprehension (as pylint requests), the dict won't actually sort.
self._attr_extra_state_attributes = (
Expand Down
13 changes: 6 additions & 7 deletions custom_components/nyc311/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Binary sensor API entity."""

from __future__ import annotations

from datetime import date, datetime
Expand Down Expand Up @@ -120,13 +121,11 @@ def update_device_data(self) -> None:
else:
closure_type = "Exception"

self._attr_extra_state_attributes.update(
{
"service_name": self._calendar_entry.service_profile.name,
"closure_type": closure_type,
"date": self._calendar_entry.date.isoformat(),
}
)
self._attr_extra_state_attributes.update({
"service_name": self._calendar_entry.service_profile.name,
"closure_type": closure_type,
"date": self._calendar_entry.date.isoformat(),
})

self._attr_is_on = (
self._calendar_entry.status_profile.standardized_type
Expand Down
1 change: 1 addition & 0 deletions custom_components/nyc311/calendar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Binary sensor calendar entity."""

from __future__ import annotations

import datetime
Expand Down
1 change: 1 addition & 0 deletions custom_components/nyc311/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Config flow for NYC 311 Public Services Calendar integration."""

from __future__ import annotations

import logging
Expand Down
9 changes: 4 additions & 5 deletions custom_components/nyc311/sensor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implements 'Next Exception' sensors."""

from __future__ import annotations

import logging
Expand Down Expand Up @@ -63,11 +64,9 @@ def update_device_data(self) -> None:
CalendarType.NEXT_EXCEPTIONS
][self._calendar_entry.service_profile.service_type]

self._attr_extra_state_attributes.update(
{
"closure_type": "Exception",
}
)
self._attr_extra_state_attributes.update({
"closure_type": "Exception",
})

self._attr_native_value = self._calendar_entry.date

Expand Down

0 comments on commit 027cfe7

Please sign in to comment.