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

Improve typing of deCONZ diagnostics #69491

Merged

Conversation

Kane610
Copy link
Member

@Kane610 Kane610 commented Apr 6, 2022

Breaking change

Proposed change

  • Check web socket is initialised
homeassistant/components/deconz/diagnostics.py:28: error: Item "None" of "Optional[WSClient]" has no attribute "state"  [union-attr]

Full typing was done here #58968 and part of it split out to this PR.

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)
  • 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
  • The code has been formatted using Black (black --fast 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.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

homeassistant/components/deconz/diagnostics.py:28: error: Item "None" of "Optional[WSClient]" has no attribute "state"  [union-attr]
homeassistant/components/deconz/diagnostics.py:40: error: Unpacking a string is disallowed  [misc]
homeassistant/components/deconz/diagnostics.py:40: error: Cannot determine type of "k"  [has-type]
homeassistant/components/deconz/diagnostics.py:40: error: Cannot determine type of "v"  [has-type]
homeassistant/components/deconz/diagnostics.py:42: error: Unpacking a string is disallowed  [misc]
homeassistant/components/deconz/diagnostics.py:42: error: Cannot determine type of "k"  [has-type]
homeassistant/components/deconz/diagnostics.py:42: error: Cannot determine type of "v"  [has-type]
Copy link
Contributor

@davet2001 davet2001 left a comment

Choose a reason for hiding this comment

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

The code changes look good to me.

The title of the PR doesn't seem to fit the change?

I assume that there are either no collisions merging these dicts or that the collisions don't matter. Is that true?

@Kane610
Copy link
Member Author

Kane610 commented Apr 9, 2022

Isn't the PR improving the typing of deconz diagnostics platform? :)

Exactly. The end result should look the same. There are no duplication of data between those different classes as the data will only be put into one of them

@davet2001
Copy link
Contributor

I suppose I was looking for type hints etc. But yes I suppose so!

@Kane610
Copy link
Member Author

Kane610 commented Apr 10, 2022

Thanks @davet2001

Copy link
Contributor

@chishm chishm left a comment

Choose a reason for hiding this comment

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

This is a case where maintainability is hindered by Mypy, in that you now have to remember to update this function if the api.lights and api.sensors groups ever change. It might be better to stick with the original code that uses groups, and cast as needed.

homeassistant/components/deconz/diagnostics.py Outdated Show resolved Hide resolved
homeassistant/components/deconz/diagnostics.py Outdated Show resolved Hide resolved
… library which I will do once I resolve as much as possible in the integration
@chishm
Copy link
Contributor

chishm commented Apr 14, 2022 via email

@Kane610
Copy link
Member Author

Kane610 commented Apr 14, 2022

No worries! Thanks for working in the deconz integration, it's the first thing I ever connected HA to.

Thanks for using it and giving back to the community!

@Kane610 Kane610 merged commit c920d7d into home-assistant:dev Apr 14, 2022
@Kane610 Kane610 deleted the deconz-improve_typing_of_deconz_diagnostics branch April 14, 2022 21:04
@github-actions github-actions bot locked and limited conversation to collaborators Apr 15, 2022
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.

4 participants