Skip to content

Tado code quality improvements#107678

Merged
edenhaus merged 22 commits into
home-assistant:devfrom
erwindouna:tado-binary-sensor-typing
Feb 28, 2024
Merged

Tado code quality improvements#107678
edenhaus merged 22 commits into
home-assistant:devfrom
erwindouna:tado-binary-sensor-typing

Conversation

@erwindouna
Copy link
Copy Markdown
Member

@erwindouna erwindouna commented Jan 9, 2024

Breaking change

Proposed change

Refactor the files Binary Sensor, Climate and Water Heater to be more strict and add typing where missing. Also some various code improvements have been made to make code less redundant and fit with typing.

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.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link
Copy Markdown
Contributor

home-assistant Bot commented Jan 9, 2024

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

Code owner commands

Code owners of tado 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 tado 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.

@erwindouna erwindouna changed the title Code quality improvements to Binary Sensor Tado code quality improvements to Binary Sensor Jan 9, 2024
@erwindouna erwindouna marked this pull request as ready for review January 9, 2024 18:50
@erwindouna erwindouna changed the title Tado code quality improvements to Binary Sensor Tado code quality improvements to Binary Sensor, Climate and Water Heater Jan 9, 2024
@michaelarnauts michaelarnauts removed their assignment Jan 10, 2024
Comment thread homeassistant/components/tado/climate.py Outdated
Comment thread homeassistant/components/tado/climate.py Outdated
Comment thread homeassistant/components/tado/climate.py Outdated
Copy link
Copy Markdown
Member

@edenhaus edenhaus left a comment

Choose a reason for hiding this comment

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

Please update the description, as there are changes outside the binary sensor.
It looks like there are also some bug fixes. Please add them to the description, too

self._attr_fan_modes = supported_fan_modes
self._attr_supported_features = support_flags

# Why are they here? Part of generic thermostat it seems? Need to be set?
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this question here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

They seem unused. Is needed for all climate controls? I simply don't know why it's there at this point.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Then please remove them if they are not used in the parent classes.

Comment thread homeassistant/components/tado/climate.py Outdated
Comment thread homeassistant/components/tado/climate.py Outdated

def _normalize_target_temp_for_hvac_mode(self):
def _normalize_target_temp_for_hvac_mode(self) -> None:
def adjust_temp(min_temp, max_temp):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this an inline function?
It should be a util function IMHO

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The only use case is within this function. That's why I put it inline.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Pleas ad typing to it

Comment thread homeassistant/components/tado/climate.py Outdated
Comment thread homeassistant/components/tado/water_heater.py Outdated
Comment thread homeassistant/components/tado/water_heater.py Outdated
Comment thread homeassistant/components/tado/water_heater.py Outdated
@home-assistant home-assistant Bot marked this pull request as draft January 10, 2024 16:34
@home-assistant
Copy link
Copy Markdown
Contributor

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.

erwindouna and others added 2 commits January 10, 2024 18:42
@erwindouna erwindouna requested a review from edenhaus January 10, 2024 17:48
@erwindouna erwindouna marked this pull request as ready for review January 10, 2024 17:48
self._attr_fan_modes = supported_fan_modes
self._attr_supported_features = support_flags

# Why are they here? Part of generic thermostat it seems? Need to be set?
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Then please remove them if they are not used in the parent classes.


def _normalize_target_temp_for_hvac_mode(self):
def _normalize_target_temp_for_hvac_mode(self) -> None:
def adjust_temp(min_temp, max_temp):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Pleas ad typing to it

Comment thread homeassistant/components/tado/climate.py Outdated
@home-assistant home-assistant Bot marked this pull request as draft January 24, 2024 14:19
@erwindouna erwindouna marked this pull request as ready for review February 25, 2024 18:39
@home-assistant home-assistant Bot requested a review from edenhaus February 25, 2024 18:39
Copy link
Copy Markdown
Member

@edenhaus edenhaus left a comment

Choose a reason for hiding this comment

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

If the integration is completely typed we can add tado to .strict-typing and add a section for it in mypy.ini (If not already done)

Comment thread homeassistant/components/tado/water_heater.py Outdated
Comment thread homeassistant/components/tado/water_heater.py Outdated
Comment thread homeassistant/components/tado/water_heater.py Outdated
Comment thread homeassistant/components/tado/water_heater.py Outdated
@home-assistant home-assistant Bot marked this pull request as draft February 27, 2024 13:02
@erwindouna
Copy link
Copy Markdown
Member Author

If the integration is completely typed we can add tado to .strict-typing and add a section for it in mypy.ini (If not already done)

This would also require the __init__.py. This is a rather large one. May I suggest to do that in a separate PR and then add it to .strict-typing?

@erwindouna erwindouna marked this pull request as ready for review February 27, 2024 14:37
@home-assistant home-assistant Bot requested a review from edenhaus February 27, 2024 14:37
Copy link
Copy Markdown
Member

@edenhaus edenhaus left a comment

Choose a reason for hiding this comment

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

Thanks @erwindouna 👍

@edenhaus edenhaus changed the title Tado code quality improvements to Binary Sensor, Climate and Water Heater Tado code quality improvements Feb 28, 2024
@edenhaus edenhaus merged commit c52e203 into home-assistant:dev Feb 28, 2024
@erwindouna erwindouna deleted the tado-binary-sensor-typing branch February 28, 2024 11:04
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 29, 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.

4 participants