python / python/cpython

Modernize annotation usage in libregrtest

Aperta
#156,402 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

tests topic-typing type-refactor
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da Lib/test/libregrtest/results.py e Lib/test/libregrtest/mypy.ini; esamina la configurazione esistente delle annotazioni e del controllo dei tipi, quindi confronta l’approccio di pyrepl in gh-149985 e gh-149992. Il lavoro è completato quando vengono utilizzati il lazy annotation import e la runtime annotation senza eager XML imports e mypy ha come obiettivo Python 3.15.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
testing-qa
Tipo di issue
Refactoring
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.