-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Fix mypy issues in zha core modules #74028
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
Conversation
Hey there @dmulcahey, @Adminiuga, mind taking a look at this pull request as it has been labeled with an integration ( |
@@ -428,6 +430,7 @@ def _cleanup_group_entity_registry_entries( | |||
] | |||
|
|||
# then we get all group entity entries tied to the coordinator | |||
assert self.coordinator_zha_device |
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.
self.coordinator_zha_device.device_id
would have failed if self.coordinator_zha_device
was None.
ZHAGroupMember( | ||
self, self._zha_gateway.devices.get(member_ieee), endpoint_id | ||
) | ||
ZHAGroupMember(self, self._zha_gateway.devices[member_ieee], endpoint_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.
There is a check in the list comprehension for if member_ieee in self._zha_gateway.devices
so we know it is present.
@@ -78,7 +78,7 @@ def member_info(self) -> dict[str, Any]: | |||
return member_info | |||
|
|||
@property | |||
def associated_entities(self) -> list[GroupEntityReference]: | |||
def associated_entities(self) -> list[dict[str, Any]]: |
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 think that _asdict()
makes this a better type hint
@@ -819,7 +819,7 @@ async def _async_group_binding_operation( | |||
fmt = f"{log_msg[1]} completed: %s" | |||
zdo.debug(fmt, *(log_msg[2] + (outcome,))) | |||
|
|||
def log(self, level: int, msg: str, *args: Any, **kwargs: dict) -> None: | |||
def log(self, level: int, msg: str, *args: Any, **kwargs: Any) -> None: |
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 **kwargs
type hints, we need to specify only the value type of the dict, not the dict itself.
@@ -276,7 +276,7 @@ def is_groupable(self) -> bool: | |||
@property | |||
def skip_configuration(self) -> bool: | |||
"""Return true if the device should not issue configuration related commands.""" | |||
return self._zigpy_device.skip_configuration or self.is_coordinator | |||
return self._zigpy_device.skip_configuration or bool(self.is_coordinator) |
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.
self.is_coordinator
can be None
, so we need to convert falsey values to a proper boolean.
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.
Lgtm
Needs #74079 to get the CI pass |
Proposed change
Fix mypy issues in zha device, gateway, group and helpers
Linked to #73603
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: