-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic type hints to acmeda #62736
Conversation
Hey there @atmurray, mind taking a look at this pull request as it has been labeled with an integration ( |
"""Set up the Acmeda Rollers from a config entry.""" | ||
hub = hass.data[DOMAIN][config_entry.entry_id] | ||
|
||
current = set() | ||
current: set[str] = set() |
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 am not 100% sure about the type hint. It seems to be a unique_id, which I assume to be a string.
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 have traced it to an integer in aiopulse
: roller_id, ptr = utils.unpack_int(message, ptr, 6)
See https://github.com/atmurray/aiopulse/blob/0d6dc539b739c5ea22a8729293526edb3090536c/aiopulse/hub.py#L270-L278
"""Set up the Acmeda Rollers from a config entry.""" | ||
hub = hass.data[DOMAIN][config_entry.entry_id] | ||
|
||
current = set() | ||
current: set[str] = set() |
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.
Same here: I am not 100% sure about the type hint. It seems to be a unique_id, which I assume to be a string.
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 have traced it to an integer in aiopulse
: roller_id, ptr = utils.unpack_int(message, ptr, 6)
See https://github.com/atmurray/aiopulse/blob/0d6dc539b739c5ea22a8729293526edb3090536c/aiopulse/hub.py#L270-L278
hass: HomeAssistant, | ||
entity_class: type, | ||
config_entry: ConfigEntry, | ||
current: set[str], |
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 is where the set is used.
unique_id
is defined in line 27:for unique_id, roller in api.items()
- and then added to
current
on line 31:current.add(unique_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.
I have traced it to an integer in aiopulse
: roller_id, ptr = utils.unpack_int(message, ptr, 6)
See https://github.com/atmurray/aiopulse/blob/0d6dc539b739c5ea22a8729293526edb3090536c/aiopulse/hub.py#L270-L278
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.
Yes, looks right to me.
hass: HomeAssistant, | ||
entity_class: type, | ||
config_entry: ConfigEntry, | ||
current: set[str], |
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.
Yes, looks right to me.
Co-authored-by: epenet <epenet@users.noreply.github.com>
Proposed change
Is there an appetite for additional type hints like these, even if it doesn't cover all the code?
I think it's a first step, and encourages future contributors to add more type hints.
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: