python / python/mypy

stubtest: Support `type_check_only` decorator

Aperta
#15,146 4 commenti 3 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

feature topic-stubtest
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Merge medio
1g 18h
PR unite (30g)
54

Descrizione

Feature

I would like stubtest to support checking the type_check_only decorator.
This means something marked with type_check_only that DOES exist at runtime is an error.
And something that DOES NOT exist at runtime, and is marked with type_check_only should pass.

Pitch

Instead of marking stub-only classes and methods as private in typeshed, they can be marked with @type_check_only, which is designed for that exact purpose. Private may or may not be found at runtime, and users sometimes don't have a choice to use them, and basically have to guess whether they need to wrap the import in TYPE_CHECK_ONLY or not.
This would also promote marking as type_check_only special methods that don't exist at runtime, but are added to support some typechecker features, in typeshed.

Related: https://github.com/python/mypy/issues/9531

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 tracciando il punto di ingresso di stubtest e la gestione esistente dei decoratori e dei controlli di presenza a runtime. Confronta il comportamento richiesto per @type_check_only con i test attuali di stubtest e l’utilizzo in typeshed. Il lavoro è completato quando vengono segnalate le dichiarazioni type_check_only presenti a runtime, mentre quelle assenti passano, con copertura per entrambi i casi.

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

Valutazione

Stack tecnologico
python
Ambito
testing-qa
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.