Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6a67143

Browse files
authored
Add setup type hints [a] (home-assistant#63424)
Co-authored-by: epenet <epenet@users.noreply.github.com>
1 parent eed6ca5 commit 6a67143

File tree

6 files changed

+59
-17
lines changed

6 files changed

+59
-17
lines changed

‎homeassistant/components/airtouch4/climate.py‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""AirTouch 4 component to control of AirTouch 4 Climate Devices."""
2+
from __future__ import annotations
23

34
import logging
45

@@ -19,9 +20,11 @@
1920
SUPPORT_FAN_MODE,
2021
SUPPORT_TARGET_TEMPERATURE,
2122
)
23+
from homeassistant.config_entries import ConfigEntry
2224
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
23-
from homeassistant.core import callback
25+
from homeassistant.core import HomeAssistant, callback
2426
from homeassistant.helpers.entity import DeviceInfo
27+
from homeassistant.helpers.entity_platform import AddEntitiesCallback
2528
from homeassistant.helpers.update_coordinator import CoordinatorEntity
2629

2730
from .const import DOMAIN
@@ -63,14 +66,21 @@
6366
_LOGGER = logging.getLogger(__name__)
6467

6568

66-
async def async_setup_entry(hass, config_entry, async_add_entities):
69+
async def async_setup_entry(
70+
hass: HomeAssistant,
71+
config_entry: ConfigEntry,
72+
async_add_entities: AddEntitiesCallback,
73+
) -> None:
6774
"""Set up the Airtouch 4."""
6875
coordinator = hass.data[DOMAIN][config_entry.entry_id]
6976
info = coordinator.data
70-
entities = [
77+
entities: list[ClimateEntity] = [
7178
AirtouchGroup(coordinator, group["group_number"], info)
7279
for group in info["groups"]
73-
] + [AirtouchAC(coordinator, ac["ac_number"], info) for ac in info["acs"]]
80+
]
81+
entities.extend(
82+
AirtouchAC(coordinator, ac["ac_number"], info) for ac in info["acs"]
83+
)
7484

7585
_LOGGER.debug(" Found entities %s", entities)
7686

‎homeassistant/components/alpha_vantage/sensor.py‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"""Stock market information from Alpha Vantage."""
2+
from __future__ import annotations
3+
24
from datetime import timedelta
35
import logging
46

@@ -8,7 +10,10 @@
810

911
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
1012
from homeassistant.const import ATTR_ATTRIBUTION, CONF_API_KEY, CONF_CURRENCY, CONF_NAME
13+
from homeassistant.core import HomeAssistant
1114
import homeassistant.helpers.config_validation as cv
15+
from homeassistant.helpers.entity_platform import AddEntitiesCallback
16+
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
1217

1318
_LOGGER = logging.getLogger(__name__)
1419

@@ -61,7 +66,12 @@
6166
)
6267

6368

64-
def setup_platform(hass, config, add_entities, discovery_info=None):
69+
def setup_platform(
70+
hass: HomeAssistant,
71+
config: ConfigType,
72+
add_entities: AddEntitiesCallback,
73+
discovery_info: DiscoveryInfoType | None = None,
74+
) -> None:
6575
"""Set up the Alpha Vantage sensor."""
6676
api_key = config[CONF_API_KEY]
6777
symbols = config.get(CONF_SYMBOLS, [])
@@ -75,7 +85,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
7585

7686
timeseries = TimeSeries(key=api_key)
7787

78-
dev = []
88+
dev: list[SensorEntity] = []
7989
for symbol in symbols:
8090
try:
8191
_LOGGER.debug("Configuring timeseries for symbols: %s", symbol[CONF_SYMBOL])

‎homeassistant/components/anel_pwrctrl/switch.py‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"""Support for ANEL PwrCtrl switches."""
2+
from __future__ import annotations
3+
24
from datetime import timedelta
35
import logging
46

@@ -7,7 +9,10 @@
79

810
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
911
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
12+
from homeassistant.core import HomeAssistant
1013
import homeassistant.helpers.config_validation as cv
14+
from homeassistant.helpers.entity_platform import AddEntitiesCallback
15+
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
1116
from homeassistant.util import Throttle
1217

1318
_LOGGER = logging.getLogger(__name__)
@@ -28,7 +33,12 @@
2833
)
2934

3035

31-
def setup_platform(hass, config, add_entities, discovery_info=None):
36+
def setup_platform(
37+
hass: HomeAssistant,
38+
config: ConfigType,
39+
add_entities: AddEntitiesCallback,
40+
discovery_info: DiscoveryInfoType | None = None,
41+
) -> None:
3242
"""Set up PwrCtrl devices/switches."""
3343
host = config.get(CONF_HOST)
3444
username = config[CONF_USERNAME]
@@ -46,9 +56,9 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
4656
master.query(ip_addr=host)
4757
except OSError as ex:
4858
_LOGGER.error("Unable to discover PwrCtrl device: %s", str(ex))
49-
returnFalse
59+
return
5060

51-
devices = []
61+
devices: list[SwitchEntity] = []
5262
for device in master.devices.values():
5363
parent_device = PwrCtrlDevice(device)
5464
devices.extend(

‎homeassistant/components/api/__init__.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@
2828
URL_API_TEMPLATE,
2929
)
3030
import homeassistant.core as ha
31+
from homeassistant.core import HomeAssistant
3132
from homeassistant.exceptions import ServiceNotFound, TemplateError, Unauthorized
3233
from homeassistant.helpers import template
3334
from homeassistant.helpers.json import JSONEncoder
3435
from homeassistant.helpers.service import async_get_all_descriptions
36+
from homeassistant.helpers.typing import ConfigType
3537

3638
_LOGGER = logging.getLogger(__name__)
3739

@@ -49,7 +51,7 @@
4951
STREAM_PING_INTERVAL = 50 # seconds
5052

5153

52-
async def async_setup(hass, config):
54+
async def async_setup(hass: HomeAssistant, config: ConfigType) ->bool:
5355
"""Register the API with the HTTP interface."""
5456
hass.http.register_view(APIStatusView)
5557
hass.http.register_view(APIEventStream)

‎homeassistant/components/arest/switch.py‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Support for an exposed aREST RESTful API of a device."""
2+
from __future__ import annotations
23

34
from http import HTTPStatus
45
import logging
@@ -8,7 +9,10 @@
89

910
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
1011
from homeassistant.const import CONF_NAME, CONF_RESOURCE
12+
from homeassistant.core import HomeAssistant
1113
import homeassistant.helpers.config_validation as cv
14+
from homeassistant.helpers.entity_platform import AddEntitiesCallback
15+
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
1216

1317
_LOGGER = logging.getLogger(__name__)
1418

@@ -39,7 +43,12 @@
3943
)
4044

4145

42-
def setup_platform(hass, config, add_entities, discovery_info=None):
46+
def setup_platform(
47+
hass: HomeAssistant,
48+
config: ConfigType,
49+
add_entities: AddEntitiesCallback,
50+
discovery_info: DiscoveryInfoType | None = None,
51+
) -> None:
4352
"""Set up the aREST switches."""
4453
resource = config[CONF_RESOURCE]
4554

@@ -49,12 +58,12 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
4958
_LOGGER.error(
5059
"Missing resource or schema in configuration. Add http:// to your URL"
5160
)
52-
returnFalse
61+
return
5362
except requests.exceptions.ConnectionError:
5463
_LOGGER.error("No route to device at %s", resource)
55-
returnFalse
64+
return
5665

57-
dev = []
66+
dev: list[SwitchEntity] = []
5867
pins = config[CONF_PINS]
5968
for pinnum, pin in pins.items():
6069
dev.append(

‎homeassistant/components/asterisk_mbox/__init__.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
import voluptuous as vol
1111

1212
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT
13-
from homeassistant.core import callback
13+
from homeassistant.core import HomeAssistant, callback
1414
from homeassistant.helpers import discovery
1515
import homeassistant.helpers.config_validation as cv
1616
from homeassistant.helpers.dispatcher import async_dispatcher_send, dispatcher_connect
17+
from homeassistant.helpers.typing import ConfigType
1718

1819
_LOGGER = logging.getLogger(__name__)
1920

@@ -39,9 +40,9 @@
3940
)
4041

4142

42-
def setup(hass, config):
43+
def setup(hass: HomeAssistant, config: ConfigType) ->bool:
4344
"""Set up for the Asterisk Voicemail box."""
44-
conf = config.get(DOMAIN)
45+
conf = config[DOMAIN]
4546

4647
host = conf[CONF_HOST]
4748
port = conf[CONF_PORT]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /