-
-
Notifications
You must be signed in to change notification settings - Fork 38.3k
Add setup type hints to yamaha #63811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
84fb677
fd52742
b89f39f
9c72f20
f93b84f
70fd267
1137dcb
6251241
51fc5b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,9 @@ | |
| STATE_ON, | ||
| STATE_PLAYING, | ||
| ) | ||
| from homeassistant.core import HomeAssistant | ||
| from homeassistant.helpers import config_validation as cv, entity_platform | ||
| from homeassistant.helpers.entity_platform import AddEntitiesCallback | ||
| from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType | ||
|
|
||
| from .const import ( | ||
|
|
@@ -99,14 +101,16 @@ | |
| class YamahaConfigInfo: | ||
| """Configuration Info for Yamaha Receivers.""" | ||
|
|
||
| def __init__(self, config: ConfigType, discovery_info: DiscoveryInfoType) -> None: | ||
| def __init__( | ||
| self, config: ConfigType, discovery_info: DiscoveryInfoType | None | ||
| ) -> None: | ||
| """Initialize the Configuration Info for Yamaha Receiver.""" | ||
| self.name = config.get(CONF_NAME) | ||
| self.host = config.get(CONF_HOST) | ||
| self.ctrl_url: str | None = f"http://{self.host}:80/YamahaRemoteControl/ctrl" | ||
| self.source_ignore = config.get(CONF_SOURCE_IGNORE) | ||
| self.source_names = config.get(CONF_SOURCE_NAMES) | ||
| self.zone_ignore = config.get(CONF_ZONE_IGNORE) | ||
| self.zone_ignore = config.get(CONF_ZONE_IGNORE, []) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be handled automatically be the schema validation, but it seemed easier to change it here than to adjust the tests. I'm happy to adjust the tests instead if so desired.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, in this location, it isn't correct. So, we should adjust the tests in that case.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I struggled a bit with that one as I am not so familiar with the test. |
||
| self.zone_names = config.get(CONF_ZONE_NAMES) | ||
| self.from_discovery = False | ||
| if discovery_info is not None: | ||
|
|
@@ -138,9 +142,13 @@ def _discovery(config_info): | |
| return receivers | ||
|
|
||
|
|
||
| async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): | ||
| async def async_setup_platform( | ||
| hass: HomeAssistant, | ||
| config: ConfigType, | ||
| async_add_entities: AddEntitiesCallback, | ||
| discovery_info: DiscoveryInfoType | None = None, | ||
| ) -> None: | ||
| """Set up the Yamaha platform.""" | ||
|
|
||
| # Keep track of configured receivers so that we don't end up | ||
| # discovering a receiver dynamically that we have static config | ||
| # for. Map each device from its zone_id . | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
discovery_infowasn't optional, it wouldn't make sense to check it afterwards: