mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 19:57:07 +00:00
Add bitcoin to strict typing (#85049)
This commit is contained in:
parent
a0d41e1d97
commit
4cea5420b3
@ -69,6 +69,7 @@ homeassistant.components.backup.*
|
|||||||
homeassistant.components.baf.*
|
homeassistant.components.baf.*
|
||||||
homeassistant.components.bayesian.*
|
homeassistant.components.bayesian.*
|
||||||
homeassistant.components.binary_sensor.*
|
homeassistant.components.binary_sensor.*
|
||||||
|
homeassistant.components.bitcoin.*
|
||||||
homeassistant.components.blockchain.*
|
homeassistant.components.blockchain.*
|
||||||
homeassistant.components.bluetooth.*
|
homeassistant.components.bluetooth.*
|
||||||
homeassistant.components.bluetooth_tracker.*
|
homeassistant.components.bluetooth_tracker.*
|
||||||
|
@ -20,12 +20,8 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ATTRIBUTION = "Data provided by blockchain.com"
|
|
||||||
|
|
||||||
DEFAULT_CURRENCY = "USD"
|
DEFAULT_CURRENCY = "USD"
|
||||||
|
|
||||||
ICON = "mdi:currency-btc"
|
|
||||||
|
|
||||||
SCAN_INTERVAL = timedelta(minutes=5)
|
SCAN_INTERVAL = timedelta(minutes=5)
|
||||||
|
|
||||||
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||||
@ -167,10 +163,12 @@ def setup_platform(
|
|||||||
class BitcoinSensor(SensorEntity):
|
class BitcoinSensor(SensorEntity):
|
||||||
"""Representation of a Bitcoin sensor."""
|
"""Representation of a Bitcoin sensor."""
|
||||||
|
|
||||||
_attr_attribution = ATTRIBUTION
|
_attr_attribution = "Data provided by blockchain.com"
|
||||||
_attr_icon = ICON
|
_attr_icon = "mdi:currency-btc"
|
||||||
|
|
||||||
def __init__(self, data, currency, description: SensorEntityDescription):
|
def __init__(
|
||||||
|
self, data: BitcoinData, currency: str, description: SensorEntityDescription
|
||||||
|
) -> None:
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
self.data = data
|
self.data = data
|
||||||
@ -231,12 +229,10 @@ class BitcoinSensor(SensorEntity):
|
|||||||
class BitcoinData:
|
class BitcoinData:
|
||||||
"""Get the latest data and update the states."""
|
"""Get the latest data and update the states."""
|
||||||
|
|
||||||
def __init__(self):
|
stats: statistics.Stats
|
||||||
"""Initialize the data object."""
|
ticker: dict[str, exchangerates.Currency]
|
||||||
self.stats = None
|
|
||||||
self.ticker = None
|
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Get the latest data from blockchain.com."""
|
"""Get the latest data from blockchain.com."""
|
||||||
|
|
||||||
self.stats = statistics.get()
|
self.stats = statistics.get()
|
||||||
|
10
mypy.ini
10
mypy.ini
@ -443,6 +443,16 @@ disallow_untyped_defs = true
|
|||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unreachable = true
|
warn_unreachable = true
|
||||||
|
|
||||||
|
[mypy-homeassistant.components.bitcoin.*]
|
||||||
|
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.blockchain.*]
|
[mypy-homeassistant.components.blockchain.*]
|
||||||
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