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

Abierto
#901 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
Medio día
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python
Área
testing

Línea de trabajo

The warnings come from the pinned pytest-asyncio 0.26 in the testing dependency group in pyproject.toml (line 51), so the pin is the place to look. The fix is already in draft PR #695, which changes the pin and adapts tests/conftest.py away from the removed event_loop fixture; start by reading that diff and PR #776 rather than starting fresh. Done means the Python 3.14 CI job no longer shows the policy deprecation annotations and the test suite still passes.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

  • #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.
  • #695 — Bump pytest-asyncio to 1.3.0 (draft). This is the one that fixes this issue. Brought up to date in 9f981514: 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.
  • #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.
  • #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

  • 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.
  • 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 c556ae20 on 2026-09-20.

Lenguaje dominante
Python
Estrellas
96
Forks
84
Merge medio
3 d 1 h
PR fusionados (30 d)
13

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de zigpy/zha

Todos los issues de zigpy/zha

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.