diff --git a/.strict-typing b/.strict-typing index 5f5a85034d8..d79922d8e7b 100644 --- a/.strict-typing +++ b/.strict-typing @@ -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.* diff --git a/homeassistant/components/bitcoin/sensor.py b/homeassistant/components/bitcoin/sensor.py index f8a38bbe470..29a7957fde7 100644 --- a/homeassistant/components/bitcoin/sensor.py +++ b/homeassistant/components/bitcoin/sensor.py @@ -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() diff --git a/mypy.ini b/mypy.ini index 53cf4726a82..e16e6534ec9 100644 --- a/mypy.ini +++ b/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