mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Add strict typing to GPSD (#100030)
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
This commit is contained in:
parent
e3837cd1e0
commit
f2fac40019
@ -141,6 +141,7 @@ homeassistant.components.glances.*
|
|||||||
homeassistant.components.goalzero.*
|
homeassistant.components.goalzero.*
|
||||||
homeassistant.components.google.*
|
homeassistant.components.google.*
|
||||||
homeassistant.components.google_sheets.*
|
homeassistant.components.google_sheets.*
|
||||||
|
homeassistant.components.gpsd.*
|
||||||
homeassistant.components.greeneye_monitor.*
|
homeassistant.components.greeneye_monitor.*
|
||||||
homeassistant.components.group.*
|
homeassistant.components.group.*
|
||||||
homeassistant.components.guardian.*
|
homeassistant.components.guardian.*
|
||||||
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import socket
|
import socket
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from gps3.agps3threaded import AGPS3mechanism
|
from gps3.agps3threaded import AGPS3mechanism
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -48,9 +49,9 @@ def setup_platform(
|
|||||||
discovery_info: DiscoveryInfoType | None = None,
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the GPSD component."""
|
"""Set up the GPSD component."""
|
||||||
name = config.get(CONF_NAME)
|
name = config[CONF_NAME]
|
||||||
host = config.get(CONF_HOST)
|
host = config[CONF_HOST]
|
||||||
port = config.get(CONF_PORT)
|
port = config[CONF_PORT]
|
||||||
|
|
||||||
# Will hopefully be possible with the next gps3 update
|
# Will hopefully be possible with the next gps3 update
|
||||||
# https://github.com/wadda/gps3/issues/11
|
# https://github.com/wadda/gps3/issues/11
|
||||||
@ -77,7 +78,13 @@ def setup_platform(
|
|||||||
class GpsdSensor(SensorEntity):
|
class GpsdSensor(SensorEntity):
|
||||||
"""Representation of a GPS receiver available via GPSD."""
|
"""Representation of a GPS receiver available via GPSD."""
|
||||||
|
|
||||||
def __init__(self, hass, name, host, port):
|
def __init__(
|
||||||
|
self,
|
||||||
|
hass: HomeAssistant,
|
||||||
|
name: str,
|
||||||
|
host: str,
|
||||||
|
port: int,
|
||||||
|
) -> None:
|
||||||
"""Initialize the GPSD sensor."""
|
"""Initialize the GPSD sensor."""
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
self._name = name
|
self._name = name
|
||||||
@ -89,12 +96,12 @@ class GpsdSensor(SensorEntity):
|
|||||||
self.agps_thread.run_thread()
|
self.agps_thread.run_thread()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self) -> str:
|
||||||
"""Return the name."""
|
"""Return the name."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self) -> str | None:
|
||||||
"""Return the state of GPSD."""
|
"""Return the state of GPSD."""
|
||||||
if self.agps_thread.data_stream.mode == 3:
|
if self.agps_thread.data_stream.mode == 3:
|
||||||
return "3D Fix"
|
return "3D Fix"
|
||||||
@ -103,7 +110,7 @@ class GpsdSensor(SensorEntity):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self) -> dict[str, Any]:
|
||||||
"""Return the state attributes of the GPS."""
|
"""Return the state attributes of the GPS."""
|
||||||
return {
|
return {
|
||||||
ATTR_LATITUDE: self.agps_thread.data_stream.lat,
|
ATTR_LATITUDE: self.agps_thread.data_stream.lat,
|
||||||
|
10
mypy.ini
10
mypy.ini
@ -1172,6 +1172,16 @@ disallow_untyped_defs = true
|
|||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unreachable = true
|
warn_unreachable = true
|
||||||
|
|
||||||
|
[mypy-homeassistant.components.gpsd.*]
|
||||||
|
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.greeneye_monitor.*]
|
[mypy-homeassistant.components.greeneye_monitor.*]
|
||||||
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