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
Fix and enable type checks in Rituals Perfume Genie #49947
Conversation
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.
馃憤 for the removing it from ignored modules.
Please see my comments on #49898 regarding storing extra data inside DataUpdateCoordinator
. But we can address this in the next PR.
Actually there's simpler solution. Just add explicit type annotation for coordinator field: #49898 (comment) coordinator: RitualsDataUpdateCoordinator |
I think I have done that? |
@@ -24,7 +24,10 @@ class DiffuserEntity(CoordinatorEntity): | |||
"""Representation of a diffuser entity.""" | |||
|
|||
def __init__( | |||
self, diffuser: Diffuser, coordinator: CoordinatorEntity, entity_suffix: str | |||
self, |
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.
I can't see it. Should be here.
class DiffuserEntity(CoordinatorEntity):
coordinator: RitualsDataUpdateCoordinator
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.
I thought adding an annotation to the function parameter was enough.
I have added the field annotation in 5efca6b.
Why is this only necessary for the custom coordinator and why does mypy not warn about this?
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.
Why is this only necessary for the custom coordinator
This way mypy can know self.coordinator
in entity has type RitualsDataUpdateCoordinator
and not DataUpdateCoordinator
.
why does mypy not warn about this?
Because you didn't use coordinator._device
outside _async_update_data
. But if you add more fields there and start using them in entity, mypy won't able to find them. So it's just an extra annotation to let mypy know that self.coordinator
is custom entity.
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.
Looks great to me, thank you for fixing this! You need to rebase to fix conflict in mypy.ini.
@MartinHjelmare please take a look.
5efca6b
to
bfd2c67
Compare
Needs rebase again following merge of #50030 |
bfd2c67
to
87cd8e0
Compare
homeassistant/components/rituals_perfume_genie/binary_sensor.py
Outdated
Show resolved
Hide resolved
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, @milanmeu 馃憤
Proposed change
RitualsPerfumeGenieDataUpdateCoordinator
->RitualsDataUpdateCoordinator
I will add more typing and enable strict typing after this PR has merged.
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: