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.pure_energie.*
homeassistant.components.purpleair.*
homeassistant.components.pushbullet.*
homeassistant.components.pvoutput.*
homeassistant.components.qnap_qsw.*
homeassistant.components.radarr.*

View File

@ -1,4 +1,5 @@
"""Pushbullet Notification provider."""
from __future__ import annotations
from typing import Any
@ -10,7 +11,7 @@ from homeassistant.helpers.dispatcher import dispatcher_send
from .const import DATA_UPDATED
class PushBulletNotificationProvider(Listener):
class PushBulletNotificationProvider(Listener): # type: ignore[misc]
"""Provider for an account, leading to one or more sensors."""
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.helpers.typing import ConfigType, DiscoveryInfoType
from .api import PushBulletNotificationProvider
from .const import ATTR_FILE, ATTR_FILE_URL, ATTR_URL, DOMAIN
_LOGGER = logging.getLogger(__name__)
@ -34,8 +35,10 @@ async def async_get_service(
"""Get the Pushbullet notification service."""
if TYPE_CHECKING:
assert discovery_info is not None
pushbullet: PushBullet = hass.data[DOMAIN][discovery_info["entry_id"]].pushbullet
return PushBulletNotificationService(hass, pushbullet)
pb_provider: PushBulletNotificationProvider = hass.data[DOMAIN][
discovery_info["entry_id"]
]
return PushBulletNotificationService(hass, pb_provider.pushbullet)
class PushBulletNotificationService(BaseNotificationService):
@ -120,7 +123,7 @@ class PushBulletNotificationService(BaseNotificationService):
pusher: PushBullet,
email: str | None = None,
phonenumber: str | None = None,
):
) -> None:
"""Create the message content."""
kwargs = {"body": message, "title": title}
if email:

View File

@ -2411,6 +2411,16 @@ disallow_untyped_defs = true
warn_return_any = 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.*]
check_untyped_defs = true
disallow_incomplete_defs = true