Skip to content

Update dynalite library and minor changes#34618

Merged
balloob merged 5 commits intohome-assistant:devfrom
ziv1234:fix25
Apr 24, 2020
Merged

Update dynalite library and minor changes#34618
balloob merged 5 commits intohome-assistant:devfrom
ziv1234:fix25

Conversation

@ziv1234
Copy link
Copy Markdown
Contributor

@ziv1234 ziv1234 commented Apr 23, 2020

Breaking change

not a breaking change

Proposed change

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

Example entry for configuration.yaml:

# Example configuration.yaml

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

{
vol.Required(CONF_NAME): cv.string,
vol.Optional(CONF_TEMPLATE): cv.string,
vol.Optional(CONF_TEMPLATE): vol.In(DEFAULT_TEMPLATES.keys()),
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.

keys() is the default iterator.

Suggested change
vol.Optional(CONF_TEMPLATE): vol.In(DEFAULT_TEMPLATES.keys()),
vol.Optional(CONF_TEMPLATE): vol.In(DEFAULT_TEMPLATES),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done


@callback
def update_device(self, device: "DynaliteBaseDevice") -> None:
def update_device(self, device: "DynaliteBaseDevice" = None) -> None:
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.

This type should be optional since it can be none:

Suggested change
def update_device(self, device: "DynaliteBaseDevice" = None) -> None:
def update_device(self, device: Optional["DynaliteBaseDevice"] = None) -> None:
from typing import Optional

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

from .const import ENTITY_PLATFORMS, LOGGER
from .convert_config import convert_config

if TYPE_CHECKING: # pragma: no cover
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.

This needs to remain there or else the type checking won't work. (you can test it with mypy <path to file>)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

that is exactly the weird behavior i had. when i moved it from DynaliteBaseDevice to Optional, flake8 didn't let me commit because it said it is unused. When I removed it, flake8 worked and mypy had no problem (see checks below). Weird.
Perhaps I can remove the Optional[] here? Since we don't define the flag '--no-implicit-optional", if it is defined with a default value of NULL, mypy understands its Optional by default?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

in any case, i figured out that i don't need "if TYPE_CHECKING" since there is no circular dependency, so while I still don't understnad why it happened, the problem is no longer relevant

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.

Oh I missed that you import it now from the package directly. ok 👍

Copy link
Copy Markdown
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.

Ok to merge once the type checking part has been put back.

@MartinHjelmare MartinHjelmare changed the title Updated library and minor changes Update dynalite library and minor changes Apr 24, 2020
@balloob balloob merged commit 4afa2a2 into home-assistant:dev Apr 24, 2020
@lock lock Bot locked and limited conversation to collaborators Apr 25, 2020
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