Skip to content
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

Enable strict typing checking for bluesound integration #123821

Merged
merged 9 commits into from
Aug 30, 2024

Conversation

LouisChrist
Copy link
Contributor

@LouisChrist LouisChrist commented Aug 13, 2024

Proposed change

This enables strict type checking and fixes all found errors. It also includes a new pyblu version, because the old version did not have type checking itself and had some type errors.

Changelog:

All changes v0.4.0...v1.0.0

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hey there @thrawnarn, mind taking a look at this pull request as it has been labeled with an integration (bluesound) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of bluesound can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign bluesound Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@LouisChrist LouisChrist marked this pull request as ready for review August 14, 2024 11:01
@gjohansson-ST
Copy link
Member

PR description is missing a link to the changelog, or at minimum a diff between library versions

@gjohansson-ST gjohansson-ST marked this pull request as draft August 14, 2024 11:34
@LouisChrist LouisChrist marked this pull request as ready for review August 14, 2024 11:46
@LouisChrist LouisChrist force-pushed the bluesound_strict_typing branch from 924c61a to f238a56 Compare August 26, 2024 18:27
@LouisChrist LouisChrist marked this pull request as draft August 26, 2024 19:18
@LouisChrist LouisChrist marked this pull request as ready for review August 26, 2024 19:33
@LouisChrist LouisChrist marked this pull request as draft August 26, 2024 22:02
@LouisChrist LouisChrist marked this pull request as ready for review August 27, 2024 17:55
Copy link
Member

@joostlek joostlek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a merge conflict

@@ -239,15 +239,15 @@ def __init__(
self.port = port
self._polling_task: Task[None] | None = None # The actual polling task.
self._id = sync_status.id
self._last_status_update = None
self._last_status_update: datetime | None = None
self._sync_status = sync_status
self._status: Status | None = None
self._inputs: list[Input] = []
self._presets: list[Preset] = []
self._muted = False
self._master: BluesoundPlayer | None = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we in followups also phase out the usage of master/slave naming and replace that with main/secondary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure. I have a refactor for the whole player grouping thing planned. There is one thing: It will be a breaking change. There is a custom attribute master visible to the user.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does that return? If we can deprecate attributes and turn them into entities (binary or normal sensors) if possible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its a boolean. But the group_members attribute from the media_player platform might enough to replace it.

@@ -407,15 +399,15 @@ async def async_update_status(self):
)
raise

async def async_trigger_sync_on_all(self):
async def async_trigger_sync_on_all(self) -> None:
"""Trigger sync status update on all devices."""
_LOGGER.debug("Trigger sync status on all devices")

for player in self.hass.data[DATA_BLUESOUND]:
await player.force_update_sync_status()

@Throttle(SYNC_STATUS_INTERVAL)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would also be nice to maybe find a way to phase out usage of throttle, since that function spawns a number of executor threads which isn't very efficient

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a separate PR? This seems to be the wrong place the change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh definitely, just wanted to leave some remarks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure about the spawning of executor threads? I had a look at it and it seems to skip calls if they are to soon or one is still running.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I've been told

@home-assistant home-assistant bot marked this pull request as draft August 30, 2024 12:29
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@LouisChrist LouisChrist marked this pull request as ready for review August 30, 2024 18:17
@home-assistant home-assistant bot requested a review from joostlek August 30, 2024 18:17
@joostlek joostlek merged commit 7868ffa into home-assistant:dev Aug 30, 2024
39 of 40 checks passed
@LouisChrist LouisChrist deleted the bluesound_strict_typing branch August 30, 2024 18:26
@github-actions github-actions bot locked and limited conversation to collaborators Aug 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants