Add bitcoin to strict typing (#85049)

This commit is contained in:
epenet 2023-01-03 13:44:06 +01:00 committed by GitHub
parent a0d41e1d97
commit 4cea5420b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 12 deletions

View file

@ -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.*

View file

@ -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()

View file

@ -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