mirror of
https://github.com/home-assistant/core
synced 2024-10-01 18:52:05 +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.bayesian.*
|
||||
homeassistant.components.binary_sensor.*
|
||||
homeassistant.components.bitcoin.*
|
||||
homeassistant.components.blockchain.*
|
||||
homeassistant.components.bluetooth.*
|
||||
homeassistant.components.bluetooth_tracker.*
|
||||
|
|
|
@ -20,12 +20,8 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ATTRIBUTION = "Data provided by blockchain.com"
|
||||
|
||||
DEFAULT_CURRENCY = "USD"
|
||||
|
||||
ICON = "mdi:currency-btc"
|
||||
|
||||
SCAN_INTERVAL = timedelta(minutes=5)
|
||||
|
||||
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||
|
@ -167,10 +163,12 @@ def setup_platform(
|
|||
class BitcoinSensor(SensorEntity):
|
||||
"""Representation of a Bitcoin sensor."""
|
||||
|
||||
_attr_attribution = ATTRIBUTION
|
||||
_attr_icon = ICON
|
||||
_attr_attribution = "Data provided by blockchain.com"
|
||||
_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."""
|
||||
self.entity_description = description
|
||||
self.data = data
|
||||
|
@ -231,12 +229,10 @@ class BitcoinSensor(SensorEntity):
|
|||
class BitcoinData:
|
||||
"""Get the latest data and update the states."""
|
||||
|
||||
def __init__(self):
|
||||
"""Initialize the data object."""
|
||||
self.stats = None
|
||||
self.ticker = None
|
||||
stats: statistics.Stats
|
||||
ticker: dict[str, exchangerates.Currency]
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Get the latest data from blockchain.com."""
|
||||
|
||||
self.stats = statistics.get()
|
||||
|
|
10
mypy.ini
10
mypy.ini
|
@ -443,6 +443,16 @@ disallow_untyped_defs = true
|
|||
warn_return_any = 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.*]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
|
|
Loading…
Reference in a new issue