Resolve the probatio codec import before the event loop by frenck · Pull Request #183909 · home-assistant/core · GitHub
Skip to content

Resolve the probatio codec import before the event loop - #183909

Merged
frenck merged 5 commits into
devfrom
frenck/fix-probatio-codecs-blocking-import
Oct 1, 2026
Merged

frenck merged 5 commits into
devfrom
frenck/fix-probatio-codecs-blocking-import

Conversation

@frenck

@frenck frenck commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Proposed change

Probatio resolves to_field_list and to_openapi through a lazy import of probatio.codecs on first attribute access. Both are first reached from the event loop, where that import is a blocking call: one renders every config flow form, the other builds the tool schemas for a conversation turn.

Detected blocking call to import_module with args ('probatio.codecs',) inside the
event loop by integration 'http'

Resolve them in the package __init__, where probatio is already configured and which runs long before the loop exists. It costs 3.8 ms on top of importing probatio, and probatio.codecs pulls in no voluptuous of its own, so it is safe before install_as_voluptuous().

The test runs in a clean interpreter, like test_circular_imports.py. By the time an ordinary test runs, something has already imported the codecs and the assert would pass either way.

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

  • I understand the code I am submitting and can explain how it works.
  • 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.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

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 diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copilot AI balanced review requested due to automatic review settings October 1, 2026 14:59
@frenck
frenck requested a review from a team as a code owner October 1, 2026 14:59
@frenck
frenck marked this pull request as draft October 1, 2026 15:01

Copilot AI left a comment

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.

Copilot review overview

🟢 Approval recommended

The focused fix addresses the reported blocking import and includes appropriate regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Preloads Probatio’s codec module before Home Assistant starts its event loop, preventing blocking import warnings.

Changes:

  • Resolves to_field_list during package initialization.
  • Adds a clean-interpreter regression test.
File Description
homeassistant/​__init__.py Eagerly resolves the lazy codec export.
tests/​test_init.py Verifies resolution during package import.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@frenck frenck changed the title Resolve the probatio codec import before the event loop DNM: Resolve the probatio codec import before the event loop Oct 1, 2026
@codspeed

codspeed Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Copilot AI balanced review requested due to automatic review settings October 1, 2026 15:06

Copilot AI left a comment

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.

Copilot review overview

🟡 Changes recommended

The implementation appears sound, but the pull request remains a draft explicitly marked “DNM.”

Review effort: Balanced
Findings: None

Copilot AI balanced review requested due to automatic review settings October 1, 2026 15:11

Copilot AI left a comment

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.

Copilot review overview

🟡 Changes recommended

The implementation appears correct, but the title marks it DNM and the test docstring needs condensation.

Review effort: Balanced
Findings: 1 Low severity

Open (1)

Comment thread tests/test_init.py Outdated
Copilot AI balanced review requested due to automatic review settings October 1, 2026 17:24

Copilot AI left a comment

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.

Copilot review overview

🟡 Changes recommended

The regression assertion can pass without proving that the lazy facade access no longer invokes import_module.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)

Comment thread tests/test_init.py Outdated
Copilot AI balanced review requested due to automatic review settings October 1, 2026 17:32

Copilot AI left a comment

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.

Copilot review overview

🟡 Changes recommended

The implementation appears sound, but the title explicitly marks the PR as do not merge.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

@frenck frenck added this to the 2026.10.0 milestone Oct 1, 2026
@frenck frenck changed the title DNM: Resolve the probatio codec import before the event loop Resolve the probatio codec import before the event loop Oct 1, 2026
@frenck
frenck marked this pull request as ready for review October 1, 2026 18:57
@frenck
frenck merged commit b14e6f2 into dev Oct 1, 2026
56 checks passed
@frenck
frenck deleted the frenck/fix-probatio-codecs-blocking-import branch October 1, 2026 18:57
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 2, 2026
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.

Detected blocking call to import_module with args ('probatio.codecs',) inside the event loop by integration 'http'

3 participants