Skip to content

Add OptionsFlow helpers to get the current config entry#129562

Merged
epenet merged 13 commits into
home-assistant:devfrom
epenet:20241031-0954
Nov 1, 2024
Merged

Add OptionsFlow helpers to get the current config entry#129562
epenet merged 13 commits into
home-assistant:devfrom
epenet:20241031-0954

Conversation

@epenet

@epenet epenet commented Oct 31, 2024

Copy link
Copy Markdown
Contributor

Breaking change

For developpers only: assigning a value to self.config_entry in an option flow is deprecated, and will stop working in 2025.12.
Please use the read-only property instead.

Proposed change

Add self._config_entry_id and self.config_entry properties to OptionsFlow

Most option flows use OptionsFlowWithConfigEntry for the sole purpose of gaining access ot the config entry, without realising it's available already via self.handler

As a follow-up, when we have considered the mutable options property and all integrations have been updated, we should be able to deprecate/remove the OptionsFlowWithConfigEntry

cc @MartinHjelmare / @gjohansson-ST

Needs:

  • tests for the deprecation
  • blog post

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

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.

To help with the load of incoming pull requests:

@home-assistant

Copy link
Copy Markdown
Contributor

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

Code owner commands

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

@epenet epenet marked this pull request as ready for review October 31, 2024 09:46
@epenet epenet requested a review from a team as a code owner October 31, 2024 09:46
Comment thread homeassistant/config_entries.py Outdated
@gjohansson-ST

Copy link
Copy Markdown
Member

I also think maybe this PR can initiate the deprecation of OptionsFlowWithConfigEntry without logging for core integrations (as those should be fixed by next release in that case).

@epenet

epenet commented Oct 31, 2024

Copy link
Copy Markdown
Contributor Author

I also think maybe this PR can initiate the deprecation of OptionsFlowWithConfigEntry without logging for core integrations (as those should be fixed by next release in that case).

Before we initiate the deprecation, we'll need to have a replacement also for the options property, that created a mutable copy of the initial options.

That is not as often used, and I would prefer to do that in a follow-up PR.

@epenet epenet added the second-opinion-wanted Add this label when a reviewer needs a second opinion from another member. label Oct 31, 2024
@MartinHjelmare MartinHjelmare removed the second-opinion-wanted Add this label when a reviewer needs a second opinion from another member. label Oct 31, 2024
@MartinHjelmare MartinHjelmare marked this pull request as draft October 31, 2024 15:28
Comment thread homeassistant/config_entries.py Outdated
Comment thread homeassistant/config_entries.py Outdated
@epenet epenet added the deprecation Indicates a breaking change to happen in the future label Oct 31, 2024
@epenet epenet marked this pull request as ready for review October 31, 2024 20:51
@epenet epenet marked this pull request as draft October 31, 2024 20:51
@epenet epenet marked this pull request as ready for review November 1, 2024 08:39

@gjohansson-ST gjohansson-ST left a comment

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.

Thanks @epenet 👍

Comment thread tests/test_config_entries.py

@MartinHjelmare MartinHjelmare left a comment

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.

Looks good!

@epenet epenet merged commit ab5b9db into home-assistant:dev Nov 1, 2024
@epenet epenet deleted the 20241031-0954 branch November 1, 2024 11:54
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants