Skip to content

Move target selector extractor method to common module#148087

Merged
abmantis merged 6 commits into
devfrom
extract_extractor_method
Jul 7, 2025
Merged

Move target selector extractor method to common module#148087
abmantis merged 6 commits into
devfrom
extract_extractor_method

Conversation

@abmantis
Copy link
Copy Markdown
Member

@abmantis abmantis commented Jul 3, 2025

Proposed change

Since this method will also be used by trigger.py in #148086, this PR moves it to a better common location.

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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend 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
  • 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:

Comment thread homeassistant/helpers/selector.py
@abmantis abmantis marked this pull request as ready for review July 3, 2025 22:25
@abmantis abmantis requested review from a team and bdraco as code owners July 3, 2025 22:25
Comment thread homeassistant/helpers/selector.py Outdated
Comment thread homeassistant/helpers/selector.py Outdated
)


def async_extract_referenced_entity_ids(
Copy link
Copy Markdown
Member

@bdraco bdraco Jul 3, 2025

Choose a reason for hiding this comment

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

Likely there are some tests that should move to tests/helpers/test_selector.py

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The tests in test_service.py where not testing the moved method directly. Since they test methods that are still part of service.py, I've left them there.
I've now also added a new test to `test_target.py.

Comment thread homeassistant/helpers/service.py Outdated
@arturpragacz
Copy link
Copy Markdown
Member

Is this actually necessary? I'm not sure how much of a better location selector.py is over service.py.

@emontnemery
Copy link
Copy Markdown
Contributor

Is this actually necessary? I'm not sure how much of a better location selector.py is over service.py.

I agree. If we do the move, we should move the shared target stuff to a new module helpers/target.py

@abmantis
Copy link
Copy Markdown
Member Author

abmantis commented Jul 4, 2025

Is this actually necessary? I'm not sure how much of a better location selector.py is over service.py.

This will also be used by trigger.py (see #148086 ) now and not just by services.

I'll move it to helpers/target.py as suggested by @emontnemery

@abmantis abmantis marked this pull request as draft July 4, 2025 10:16
@abmantis abmantis marked this pull request as ready for review July 4, 2025 21:50
Comment thread homeassistant/helpers/service.py Outdated
class ServiceTargetSelector:
@deprecated_class(
"homeassistant.helpers.target.TargetSelectorData",
breaks_in_ha_version="2026.2",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should make the deprecation period a year since this is not something users can fix themselves

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

makes sense. do we have any written guidelines on this?

Comment thread homeassistant/helpers/service.py
@abmantis abmantis requested review from bdraco and emontnemery July 7, 2025 11:29
Copy link
Copy Markdown
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @abmantis 👍

Can be merged when CI passes

@abmantis abmantis merged commit b71bcb0 into dev Jul 7, 2025
85 of 86 checks passed
@abmantis abmantis deleted the extract_extractor_method branch July 7, 2025 12:48
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 8, 2025
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.

4 participants