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

Use Platform enum #63577

Merged
merged 1 commit into from
Jan 9, 2022
Merged

Use Platform enum #63577

merged 1 commit into from
Jan 9, 2022

Conversation

cdce8p
Copy link
Member

@cdce8p cdce8p commented Jan 7, 2022

Proposed change

Successor to #63495 and similar.

Only use Platform enum for platform APIs.
For context: #63495 (comment)

/CC @epenet: Those were the remaining changes form all my closed PRs. I do think though that your PR #63571 is the way forward.

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:

@@ -82,7 +87,7 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:

hass.data[DOMAIN] = {"channels": channels, "client": qvrpro}

load_platform(hass, CAMERA_DOMAIN, DOMAIN, {}, config)
load_platform(hass, Platform.CAMERA, DOMAIN, {}, config)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please keep this change on hold until #63571 is approved

Copy link
Member

Choose a reason for hiding this comment

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

Care to share why @epenet?
As in, the current typing is already valid? Thus this is already valid?

Copy link
Contributor

Choose a reason for hiding this comment

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

We have changed everywhere the PLATFORMS constants (or pretty much everywhere).
But for now there are 100s of places where load_platform and async_load_platform are still using a string or the imported domain. I therefore felt that since this PR was mixing up the two (some changes to PLATFORM constants, and some changes to load_platform method it was better to postpone the method changes.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I'm not following that comment, this code seems correct. It passes a platform to the load platform method... all platform 🤷

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we consider that async_setup_component allows a Platform enum?

setup_success = await setup.async_setup_component(hass, component, hass_config)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that until we approve the change to the type hint, then we shouldn't use the Platform enum more.
Thus I created PRs #63571 / #63581 to get confirmation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Both PRs have been merge. I think it's safe to merge this one now too.

homeassistant/components/amcrest/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/amcrest/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/amcrest/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/amcrest/__init__.py Outdated Show resolved Hide resolved
Copy link
Contributor

@jeeftor jeeftor left a comment

Choose a reason for hiding this comment

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

Looks much cleaner this way!

@cdce8p cdce8p added the smash Indicator this PR is close to finish for merging or closing label Jan 9, 2022
@epenet epenet merged commit 4d3f70a into home-assistant:dev Jan 9, 2022
@epenet
Copy link
Contributor

epenet commented Jan 9, 2022

I wonder if we could we use it in the config schema also? (See netgear_lte init file)

@cdce8p cdce8p deleted the import-platform branch January 9, 2022 11:38
@cdce8p
Copy link
Member Author

cdce8p commented Jan 9, 2022

I wonder if we could we use it in the config schema also? (See netgear_lte init file)

Though about that too. Would you like to open a PR with an example?

@epenet
Copy link
Contributor

epenet commented Jan 9, 2022

You can go ahead. Wont be able to create one before tomorrow.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed code-quality smash Indicator this PR is close to finish for merging or closing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants