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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove force from async_schedule_update_ha_state for HMIPC #31796

Merged
merged 2 commits into from
Feb 14, 2020
Merged

Remove force from async_schedule_update_ha_state for HMIPC #31796

merged 2 commits into from
Feb 14, 2020

Conversation

SukramJ
Copy link
Contributor

@SukramJ SukramJ commented Feb 13, 2020

Proposed change

remove force from async_schedule_update_ha_state for HMIPC.

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

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 馃 Silver
  • 馃 Gold
  • 馃弳 Platinum

@SukramJ SukramJ requested a review from balloob February 13, 2020 19:30
@project-bot project-bot bot added this to Needs review in Dev Feb 13, 2020
@project-bot project-bot bot moved this from Needs review to By Code Owner in Dev Feb 13, 2020
@SukramJ
Copy link
Contributor Author

SukramJ commented Feb 13, 2020

Hi @balloob,

this is the fix for the HomematicIP stuff of #31758

Copy link
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

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

It's always the missing callback decorators :)

Dev automation moved this from By Code Owner to Reviewer approved Feb 13, 2020
@SukramJ
Copy link
Contributor Author

SukramJ commented Feb 13, 2020

It's not only the decorator. Good that @MartinHjelmare identified the other one.

@codecov

This comment has been minimized.

@@ -95,10 +96,19 @@ def supported_features(self) -> int:
"""Register callbacks."""
self._home.on_update(self._async_device_changed)

@callback
Copy link
Member

Choose a reason for hiding this comment

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

Why does it matter if we decorate this method? Isn't this callback called from the device library in the home instance?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it makes no difference, but i thought it has to be there. should it be removed?

Copy link
Member

Choose a reason for hiding this comment

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

It doesn't hurt, but it has no effect.

Copy link
Member

Choose a reason for hiding this comment

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

It's good to have decorators on all methods that we expect to be only called inside the event loop. It helps understand the code.

Copy link
Member

Choose a reason for hiding this comment

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

We will never be able to do that everywhere. I don't think we should try.

Copy link
Member

Choose a reason for hiding this comment

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

We actually already do everywhere. See:

git grep -B1 "  def async_" | grep -v 'callback' | grep -v '\-\-' | grep -v ' def '
git grep -B1 "  def _async_" | grep -v 'callback' | grep -v '\-\-' | grep -v ' def '

I think that it makes it very clear for people reading the code about what kind of context the method can/should be called.

Copy link
Member

Choose a reason for hiding this comment

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

We'll never decorate other library functions 100%. We won't be able to trust that this decorator is the truth about this. You have to read other things in the code to find out.

It's a war we cannot win. I think we should pick our battles.

@MartinHjelmare MartinHjelmare changed the title remove force from async_schedule_update_ha_state for HMIPC Remove force from async_schedule_update_ha_state for HMIPC Feb 13, 2020
@balloob balloob merged commit 2f3ab15 into home-assistant:dev Feb 14, 2020
Dev automation moved this from Reviewer approved to Done Feb 14, 2020
@SukramJ SukramJ deleted the HmIP-ACP-RemoveForce branch February 14, 2020 06:03
@lock lock bot locked and limited conversation to collaborators Feb 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants