mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 10:17:51 +00:00
Improve OpenSky typing (#93666)
* Add types to OpenSky * Update .strict-typing * Add types to OpenSky
This commit is contained in:
parent
5f5951e71c
commit
fad3a4e168
@ -236,6 +236,7 @@ homeassistant.components.oncue.*
|
|||||||
homeassistant.components.onewire.*
|
homeassistant.components.onewire.*
|
||||||
homeassistant.components.open_meteo.*
|
homeassistant.components.open_meteo.*
|
||||||
homeassistant.components.openexchangerates.*
|
homeassistant.components.openexchangerates.*
|
||||||
|
homeassistant.components.opensky.*
|
||||||
homeassistant.components.openuv.*
|
homeassistant.components.openuv.*
|
||||||
homeassistant.components.otbr.*
|
homeassistant.components.otbr.*
|
||||||
homeassistant.components.overkiz.*
|
homeassistant.components.overkiz.*
|
||||||
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from python_opensky import BoundingBox, OpenSky
|
from python_opensky import BoundingBox, OpenSky, StateVector
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
@ -120,16 +120,18 @@ class OpenSkySensor(SensorEntity):
|
|||||||
self._bounding_box = bounding_box
|
self._bounding_box = bounding_box
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self) -> str:
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self) -> int:
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
def _handle_boundary(self, flights, event, metadata):
|
def _handle_boundary(
|
||||||
|
self, flights: set[str], event: str, metadata: dict[str, StateVector]
|
||||||
|
) -> None:
|
||||||
"""Handle flights crossing region boundary."""
|
"""Handle flights crossing region boundary."""
|
||||||
for flight in flights:
|
for flight in flights:
|
||||||
if flight in metadata:
|
if flight in metadata:
|
||||||
@ -157,7 +159,7 @@ class OpenSkySensor(SensorEntity):
|
|||||||
async def async_update(self) -> None:
|
async def async_update(self) -> None:
|
||||||
"""Update device state."""
|
"""Update device state."""
|
||||||
currently_tracked = set()
|
currently_tracked = set()
|
||||||
flight_metadata = {}
|
flight_metadata: dict[str, StateVector] = {}
|
||||||
response = await self._opensky.get_states(bounding_box=self._bounding_box)
|
response = await self._opensky.get_states(bounding_box=self._bounding_box)
|
||||||
for flight in response.states:
|
for flight in response.states:
|
||||||
if not flight.callsign:
|
if not flight.callsign:
|
||||||
@ -187,11 +189,11 @@ class OpenSkySensor(SensorEntity):
|
|||||||
self._previously_tracked = currently_tracked
|
self._previously_tracked = currently_tracked
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_unit_of_measurement(self):
|
def native_unit_of_measurement(self) -> str:
|
||||||
"""Return the unit of measurement."""
|
"""Return the unit of measurement."""
|
||||||
return "flights"
|
return "flights"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self) -> str:
|
||||||
"""Return the icon."""
|
"""Return the icon."""
|
||||||
return "mdi:airplane"
|
return "mdi:airplane"
|
||||||
|
10
mypy.ini
10
mypy.ini
@ -2122,6 +2122,16 @@ disallow_untyped_defs = true
|
|||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unreachable = true
|
warn_unreachable = true
|
||||||
|
|
||||||
|
[mypy-homeassistant.components.opensky.*]
|
||||||
|
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.openuv.*]
|
[mypy-homeassistant.components.openuv.*]
|
||||||
check_untyped_defs = true
|
check_untyped_defs = true
|
||||||
disallow_incomplete_defs = true
|
disallow_incomplete_defs = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user