Add strict typing to push bullet (#99538)

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Rami Mosleh 2023-11-30 00:05:10 +02:00 committed by GitHub
parent c8aed06438
commit 2437fb314f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 4 deletions

View File

@ -265,6 +265,7 @@ homeassistant.components.proximity.*
homeassistant.components.prusalink.* homeassistant.components.prusalink.*
homeassistant.components.pure_energie.* homeassistant.components.pure_energie.*
homeassistant.components.purpleair.* homeassistant.components.purpleair.*
homeassistant.components.pushbullet.*
homeassistant.components.pvoutput.* homeassistant.components.pvoutput.*
homeassistant.components.qnap_qsw.* homeassistant.components.qnap_qsw.*
homeassistant.components.radarr.* homeassistant.components.radarr.*

View File

@ -1,4 +1,5 @@
"""Pushbullet Notification provider.""" """Pushbullet Notification provider."""
from __future__ import annotations
from typing import Any from typing import Any
@ -10,7 +11,7 @@ from homeassistant.helpers.dispatcher import dispatcher_send
from .const import DATA_UPDATED from .const import DATA_UPDATED
class PushBulletNotificationProvider(Listener): class PushBulletNotificationProvider(Listener): # type: ignore[misc]
"""Provider for an account, leading to one or more sensors.""" """Provider for an account, leading to one or more sensors."""
def __init__(self, hass: HomeAssistant, pushbullet: PushBullet) -> None: def __init__(self, hass: HomeAssistant, pushbullet: PushBullet) -> None:

View File

@ -21,6 +21,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from .api import PushBulletNotificationProvider
from .const import ATTR_FILE, ATTR_FILE_URL, ATTR_URL, DOMAIN from .const import ATTR_FILE, ATTR_FILE_URL, ATTR_URL, DOMAIN
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -34,8 +35,10 @@ async def async_get_service(
"""Get the Pushbullet notification service.""" """Get the Pushbullet notification service."""
if TYPE_CHECKING: if TYPE_CHECKING:
assert discovery_info is not None assert discovery_info is not None
pushbullet: PushBullet = hass.data[DOMAIN][discovery_info["entry_id"]].pushbullet pb_provider: PushBulletNotificationProvider = hass.data[DOMAIN][
return PushBulletNotificationService(hass, pushbullet) discovery_info["entry_id"]
]
return PushBulletNotificationService(hass, pb_provider.pushbullet)
class PushBulletNotificationService(BaseNotificationService): class PushBulletNotificationService(BaseNotificationService):
@ -120,7 +123,7 @@ class PushBulletNotificationService(BaseNotificationService):
pusher: PushBullet, pusher: PushBullet,
email: str | None = None, email: str | None = None,
phonenumber: str | None = None, phonenumber: str | None = None,
): ) -> None:
"""Create the message content.""" """Create the message content."""
kwargs = {"body": message, "title": title} kwargs = {"body": message, "title": title}
if email: if email:

View File

@ -2411,6 +2411,16 @@ disallow_untyped_defs = true
warn_return_any = true warn_return_any = true
warn_unreachable = true warn_unreachable = true
[mypy-homeassistant.components.pushbullet.*]
check_untyped_defs = true
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_decorators = true
disallow_untyped_defs = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.pvoutput.*] [mypy-homeassistant.components.pvoutput.*]
check_untyped_defs = true check_untyped_defs = true
disallow_incomplete_defs = true disallow_incomplete_defs = true