`UNBOUND_TYPEVAR` error message should be more direct and shorter
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
*Notes:
- mypy test.py
- mypy 1.19.1
- Python 3.14.0
- Related comment
The last 3 examples get the same indirect and long error messages of UNBOUND_TYPEVAR as shown below:
*Notes:
- A parameter is a variable defined in a function header to receive an argument.
- An argument is a value passed to a function parameter.
A function returning TypeVar should receive at least one argument containing the same TypeVar
With T for x:
def func[T](x: T) -> T:
return x
# No error
Without T for x:
def func[T](x) -> T:
return x
# error: A function returning TypeVar should receive at least one argument containing the same TypeVar
With no parameters:
from typing import cast
def func[T]() -> T:
return cast(T, 'Hello')
# error: A function returning TypeVar should receive at least one argument containing the same TypeVar
With T1 for x and T2 for return type:
def func[T1, T2](x: T1) -> T2:
return x
# error: A function returning TypeVar should receive at least one argument containing the same TypeVar
So, the same indirect and long error messages of UNBOUND_TYPEVAR should be changed:
From:
A function returning TypeVar should receive at least one argument containing the same TypeVar
To more direct and shorter one below:
A function returning TypeVar should have at least one same TypeVar parameter
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con gli esempi di mypy test.py e individua dove viene generata e verificata la diagnostica UNBOUND_TYPEVAR. Aggiorna il messaggio con la formulazione più breve richiesta, quindi verifica che i tre esempi che falliscono producano la nuova diagnostica senza modificare l'esempio valido.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100