Skip to content

Python 3.14 CI: ~25k asyncio.get_event_loop_policy / set_event_loop_policy deprecation warnings, all from the pinned pytest-asyncio 0.26 #901

Open

Description

@zigpy-review-bot

The Run tests Python 3.14 job annotates every one of these calls. In https://github.com/zigpy/zha/actions/runs/32916926775/job/98022510877 that is 16,575 'asyncio.get_event_loop_policy' is deprecated and slated for removal in Python 3.16 plus 8,297 set_event_loop_policy — roughly 25k annotations in a single job, which buries the warnings that actually matter (the same log carries 82 asyncio.iscoroutinefunction ones and a handful of real quirks manufacturer_code warnings).

Source: pytest-asyncio, not zha

Every annotation that carries a file attributes to .venv/lib/python3.14/site-packages/pytest_asyncio/plugin.py (lines 772, 777, 794, 874, 942, …). zha's own package and test suite contain no get_event_loop_policy / set_event_loop_policy call at all, and the only other installed package that even mentions the API does so in a comment (freezegun).

We pin pytest-asyncio<1.0 (pyproject.toml:51, in the testing dependency group) → 0.26.0, which calls the policy API directly. pytest-asyncio 1.0.0 wrapped every one of those calls in warnings.catch_warnings() + simplefilter("ignore", DeprecationWarning) — the _get_event_loop_policy() / _set_event_loop_policy() helpers in plugin.py — and 1.4.0 (still the current release) keeps them. So getting past the pin silences all ~25k with no change on our side; no local warning filter is needed.

Open PRs in this repo — and a wrinkle in two of them

The pin moved house: requirements_test.txt was deleted in #773 (3adff2ca, 2026-05-28) when the test dependencies became the testing dependency group in pyproject.toml. Two of the three PRs below still edit that deleted file, so neither of them moves the pin that is actually in effect today.

  • Bump pytest-asyncio from 0.26.0 to 1.4.0 #776 — dependabot: Bump pytest-asyncio from 0.26.0 to 1.4.0. Touches pyproject.toml + uv.lock, i.e. the only one of the three aimed at where the pin now lives.
  • Bump pytest-asyncio to 1.4.0 #695 — Bump pytest-asyncio to 1.3.0 (draft). This is the one that fixes this issue. Brought up to date in 9f98151: dev merged, the version bump moved from requirements_test.txt to pyproject.toml, and uv.lock regenerated to 1.4.0. With it, the suite goes from 12522 warnings to 83, none of them from pytest-asyncio. The substantive half is its tests/conftest.py adaptation to the removed event_loop fixture, without which the bump cannot work.
  • Update pytest-asyncio requirement from <1.0 to <2.0 #476 — dependabot: Update pytest-asyncio requirement from <1.0 to <2.0 (open since 2025-07-16). Edits requirements_test.txt only, so it is obsolete as it stands: dependabot is configured with package-ecosystem: uv and no longer manages that file at all. Probably closable.
  • Suppress expected warnings in tests #696 — Suppress expected warnings in tests (draft). Adjacent rather than a fix for this one: it filters warnings our own tests provoke, whereas these come from the plugin.

Home Assistant Core

  • Create event loops with a factory instead of an event loop policy home-assistant/core#179871 — "Create event loops with a factory instead of an event loop policy" (balloob, merged 2026-08-25). This is the runtime half of the same 3.16 removal: HassEventLoopPolicy becomes a create_event_loop() factory, with the loop configuration moved into configure_event_loop(), and the scripts pass asyncio.run(..., loop_factory=...). zha installs no policy of its own, so there is nothing to port — but it is the reference for how the removal is being handled downstream, and worth watching if we ever want loop configuration of our own.
  • Update pytest-asyncio to 1.4.0 home-assistant/core#172886 — renovate: Update pytest-asyncio to 1.4.0 (merged 2026-06-03). HA Core is already past the pin, which is why their CI does not show this.

Related, same 3.16 removal wave

The same job logs 82 'asyncio.iscoroutinefunction' is deprecated … use inspect.iscoroutinefunction() instead warnings, and those are ours rather than the plugin's: zha/async_.py:136 is the only call site left. That half was tracked in #882 and is now fixed by #902 (merged), so it no longer contributes to the warning count. zigpy/bellows#741 already made the equivalent change there.

All PR states and file references re-verified against dev at c556ae2 on 2026-09-20.

Activity

  1. TheJulianJES commented on Sep 20, 2026

    @TheJulianJES
    Contributor

    @zigpy-review-bot Check PRs. Anything left?

  2. zigpy-review-bot commented on Sep 20, 2026

    @zigpy-review-bot
    CollaboratorAuthor

    Checked all four, plus a full local run on dev at 939b2b3.

    The issue itself is fixed. #695 merged as 939b2b3 with pytest-asyncio>=1.4.0 in pyproject.toml and the lock resolved to 1.4.0. The Run tests Python 3.14 job on that commit (https://github.com/zigpy/zha/actions/runs/35487785314/job/106017250586) carries zero get_event_loop_policy / set_event_loop_policy annotations, down from ~25k — and zero asyncio.iscoroutinefunction ones, since #902 landed just before it. A full local run on dev: 1382 passed, 83 warnings, exactly the number this issue predicted.

    PR status

    What #696 would still buy. The 83 warnings that remain on dev are exactly the two classes it filters:

    • 73 zigpy DeprecationWarnings — Attribute '<name>' has is_manufacturer_specific without an explicit manufacturer_code, from zha-quirks 2.2.2 definitions (12 distinct attributes).
    • 10 UserWarnings from tests/test_discover.py:824 — "Unique IDs are unique only with platform prefix".

    I merged #696 onto current dev in a scratch worktree: it merges cleanly — one auto-merge in tests/conftest.py, despite #695 having reworked that file — and the full suite then runs 1382 passed, 0 warnings. So it is still applicable as written and would take the 3.14 job's annotation list to empty.

    One call worth making before it lands: those 73 deprecations are genuine quirk bugs, not test noise — quirks declaring manufacturer-specific attributes without a manufacturer_code, e.g. hooks_state in zhaquirks/xiaomi/aqara/driver_curtain_e1.py, error_detected / last_feeding_size in zhaquirks/xiaomi/aqara/feeder_acn001.py, operation_preset in zhaquirks/tuya/ts0601_trv.py, plus Philips, Centralite, IKEA/Develco ones. zha cannot fix them from here, and filtering them in tests/conftest.py also removes the only place they are currently surfaced — there is no open issue for them on zha-device-handlers. Worth filing one there before suppressing, if you want them tracked. The unique-ID UserWarning is zha's own and is deliberately warn-rather-raise, so filtering that one is uncontroversial.

    Nothing else open in zha touches this. Once #696 is decided either way, this issue can be closed — closing is outside what I do on my own.

    Verification detail
    • dev at 939b2b3, worktree venv from the lock: pytest 8.4.2, pytest-asyncio 1.4.0, zha-quirks 2.2.2.
    • pytest tests/ -q: 1382 passed, 83 warnings (73 DeprecationWarning + 10 UserWarning; zero from pytest_asyncio).
    • Same worktree with Suppress expected warnings in tests #696 merged in (git merge pr-696-check — clean): pytest tests/ -q → 1382 passed, no warnings summary at all.
    • CI job log for 939b2b3 / Python 3.14: grep -c event_loop_policy → 0; grep -c asyncio.iscoroutinefunction → 0; 166 ##[warning] lines remain, all of them the two classes above.
    • Attributes triggering the deprecation: error_detected, feed, hooks_state, last_feeding_size, measured_value, mode, motion_sensitivity, operation_preset, philips, start_time, sw_error_code, x_axis (manufacturer codes 0x1037, 0x100B, 0x1015).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    None yet

    Size

    None yet

    Area

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions