Don't report "expression contains 'Any'" if it's a `TypeOfAny.from_error`
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
Update
@A5Rocks idea about not reporting expression contains Any if it's TypeOfAny.from_error is based 100. I also realized that if it's <nothing> it would still complain about attribute access etc being incorrect.
Bug Report
The reason being that when you update an overloaded signature you can get hundreds of reported "Expression contains 'Any'" errors, when there are in reality an order of magnitude less actual errors.
from typing import overload
@overload
def foo(a: int) -> int: ...
# this overload was just removed
# @overload
# def foo(a: None) -> str ...
@overload
def foo(a: str) -> str: ...
def foo(a: object) -> object: ...
a = foo(None) # error: No overload variant of "foo" matches argument type "None"\
# error: Expression has type "Any"
reveal_type(a) # error: Expression has type "Any"\
# note: Revealed type is "Any"
print(a) # error: Expression has type "Any"
bar(a) # error: Expression has type "Any"
a + "asdf" # error: Expression has type "Any"
But If TypeOfAny.from_errors are ignored:
a = foo(None) # error: No overload variant of "foo" matches argument type "None"
reveal_type(a) # note: Revealed type is "Any"
print(a)
bar(a)
a + "asdf"
Original Title
Invocations of overloaded functions with invalid argument types shouldn't return Any it should return <nothing>
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 minimi di chiamate sovraccariche nell'issue e traccia come la risoluzione di sovraccarichi non validi assegna TypeOfAny.from_error e come le espressioni successive segnalano quel tipo. Il lavoro è completato quando l'errore di sovraccarico originale rimane, mentre i valori Any di errore propagati non producono ulteriori diagnostiche "Expression has type Any"; l'issue non indica file o test da eseguire.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100