Don't report "expression contains 'Any'" if it's a `TypeOfAny.from_error`
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
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>
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit den minimalen Beispielen für überladene Aufrufe im Issue und verfolge, wie die Auflösung ungültiger Überladungen TypeOfAny.from_error zuweist und wie spätere Ausdrücke diesen Typ melden. Als abgeschlossen gilt die Änderung, wenn der ursprüngliche Überladungsfehler bestehen bleibt, während weitergegebene Any-Werte mit Fehlerstatus keine zusätzlichen Diagnosen "Expression has type Any" erzeugen; im Issue werden keine Dateien oder auszuführenden Tests genannt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100