python / python/cpython

Modernize annotation usage in libregrtest

Abierto
#156,402 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

tests topic-typing type-refactor
Lenguaje dominante
Python
Estrellas
77.2k
Forks
35.9k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

Bug description:

Lib/test/libregrtest/results.py imports TYPE_CHECKING only to guard a type-only import:

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from xml.etree.ElementTree import Element

Now that explicit lazy imports are available, this can be replaced with:

lazy from xml.etree.ElementTree import Element

The stringized list['Element'] annotation can then become list[Element]. This keeps xml.etree.ElementTree from being imported eagerly while making the annotation name available at runtime.

Lib/test/libregrtest/mypy.ini should also target Python 3.15, following the approach used for pyrepl in gh-149985 and gh-149992.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs
  • gh-156403

Guía de contribución

Abrir la guía de contribución

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.

Línea de trabajo

Empieza por Lib/test/libregrtest/results.py y Lib/test/libregrtest/mypy.ini; inspecciona la configuración existente de anotaciones y comprobación de tipos, y después compara el enfoque de pyrepl en gh-149985 y gh-149992. Se considera terminado cuando se utilizan el lazy annotation import y la runtime annotation sin eager XML imports, y mypy tiene como objetivo Python 3.15.

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

Evaluación

Stack tecnológico
python
Área
testing-qa
Tipo de issue
Refactorización
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
30/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.