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

Cleanup ENTITY_CATEGORIES_SCHEMA #66549

Merged
merged 7 commits into from
Apr 1, 2022
Merged

Conversation

epenet
Copy link
Contributor

@epenet epenet commented Feb 15, 2022

Proposed change

Cleanup ENTITY_CATEGORIES_SCHEMA
As a follow-up to #66108, and as an alternative to #66127
Requires

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:

@probot-home-assistant
Copy link

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (mobile_app) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@probot-home-assistant
Copy link

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

@probot-home-assistant
Copy link

Hey there @Julius2342, @farmio, @marvin-w, mind taking a look at this pull request as it has been labeled with an integration (knx) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@epenet epenet added the waiting-for-upstream We're waiting for a change upstream label Feb 15, 2022
@github-actions
Copy link

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@github-actions github-actions bot added the stale label Mar 17, 2022
@epenet
Copy link
Contributor Author

epenet commented Mar 18, 2022

Not stale

@epenet
Copy link
Contributor Author

epenet commented Mar 28, 2022

Rebased to resolve conflicts - still waiting on upstream release

@epenet epenet mentioned this pull request Mar 30, 2022
29 tasks
@epenet
Copy link
Contributor Author

epenet commented Mar 30, 2022

Upstream released, now waiting on dependency bump

@epenet epenet removed the waiting-for-upstream We're waiting for a change upstream label Apr 1, 2022
with pytest.raises(vol.Invalid):
with pytest.raises(
vol.Invalid,
match=r"expected EntityCategory or one of 'config', 'diagnostic', 'system'",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Home Assistant would previously raise

    value must be one of ['config', 'diagnostic', 'system']

Copy link
Member

Choose a reason for hiding this comment

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

There is a match keyword ?! that's so much easier than what I normally do.

@epenet epenet marked this pull request as ready for review April 1, 2022 08:56
@epenet epenet requested review from emontnemery, a team, farmio and marvin-w as code owners April 1, 2022 08:56
@epenet
Copy link
Contributor Author

epenet commented Apr 1, 2022

@balloob / @emontnemery / @farmio
Is there still an appetite for this?

@@ -214,6 +204,9 @@ class EntityCategory(StrEnum):
SYSTEM = "system"


ENTITY_CATEGORIES_SCHEMA: Final = vol.All(vol.Lower, vol.Coerce(EntityCategory))
Copy link
Member

Choose a reason for hiding this comment

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

Should this include str

Suggested change
ENTITY_CATEGORIES_SCHEMA: Final = vol.All(vol.Lower, vol.Coerce(EntityCategory))
ENTITY_CATEGORIES_SCHEMA: Final = vol.All(str, vol.Lower, vol.Coerce(EntityCategory))

Copy link
Member

Choose a reason for hiding this comment

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

And should we do vol.Lower? It is technically an incorrect value.

Oh I guess if we require str we're going to raise a bad error message that it's supposed to be a string.

Suggested change
ENTITY_CATEGORIES_SCHEMA: Final = vol.All(vol.Lower, vol.Coerce(EntityCategory))
ENTITY_CATEGORIES_SCHEMA: Final = vol.Coerce(EntityCategory)

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
@balloob balloob merged commit 4c7e1fe into home-assistant:dev Apr 1, 2022
@epenet epenet deleted the enum-coerce branch April 1, 2022 20:12
@github-actions github-actions bot locked and limited conversation to collaborators Apr 2, 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.

6 participants