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
Improve type hints in homeassistant scene #76930
Improve type hints in homeassistant scene #76930
Conversation
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( |
return [ | ||
scene_entity.entity_id | ||
for scene_entity in platform.entities.values() | ||
if entity_id in scene_entity.scene_config.states | ||
if entity_id in cast(HomeAssistantScene, scene_entity).scene_config.states |
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.
We could avoid the casting here.
scene_entities: list[HomeAssistantScene] = platform.entities.values()
return [
scene_entity.entity_id
for scene_entity in scene_entities
if entity_id in scene_entity.scene_config.states
]
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.
This suggestion is not working:
Incompatible types in assignment (expression has type "dict_values[str, Entity]", variable has type "List[HomeAssistantScene]") [assignment]
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.
Oh I see, maybe change it to:
return [
scene_entity.entity_id
for scene_entity in cast(
ValuesView[HomeAssistantScene], platform.entities.values()
)
if entity_id in scene_entity.scene_config.states
]
That way, we only call cast once.
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.
Done
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.
Thanks, @epenet 馃憤
Proposed change
Improve type hints in homeassistant scene
Linked to #76908
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: