Surprising results from the HTML report
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
I was able to replicate your problems on mypy master (
mypy 2.0.0+dev.3cda6ec255a530e7da8bec44d197399aec73e96d (compiled: no)), such as the@overloadthing. I think this is a bug, especially considering that the typeshed definition of overload does not containAny, but it is hard for me to say definitively (due to the lack of documentation).With the following code:
from typing import overload def foo(x): return x def foo1(x: int) -> int: return x def foo2(x) -> int: return x def foo3(x: int): return x def foo4(x: int): return x @overload def foo5(x: int) -> int: ... @overload def foo5(x: str) -> str: ... def foo5(x): return x @overload def foo6(x: int) -> int: ... @overload def foo6(x: str) -> str: ... def foo6(x: int|str) -> int|str: return xAnd the following command:
uv run mypy --html-report tmp_dir tmp.pyI get the following result:
![]()
The
@overloadlines are red but on hover say "No Anys on this line!". Surprisingly, this is also true ofdef foo(x):anddef foo5(x):My
isinstancelines are always colored green, not yellow. In fact, the lineisinstance(1,list)is green, but on hover it saysAny Types on this line: Omitted Generics (x3). I think this kind of makes sense as behavior given the rules aboutisinstancebut I think in that case the hovertext should maybe be different.In the following code, the
print("OK")line is colored red despite on hover sayingNo Anys on this line!. Theif isinstance(v,list):line is green despite sayingAny Types on this line: Omitted Generics (x3)v = 1 if isinstance(v,list): print("OK")Possibly related: https://github.com/python/mypy/issues/14297
Originally posted by @wyattscarpenter in #13495
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
Reproduziere den Bericht mit dem bereitgestellten tmp.py-Beispiel und uv run mypy --html-report tmp_dir tmp.py. Vergleiche die HTML-Farben und den Hover-Text für die Zeilen mit @overload, isinstance und nicht erreichbarem Code. Abgeschlossen ist die Aufgabe, wenn die visuellen Indikatoren und Hover-Beschreibungen des Berichts die erkannte Any-Nutzung und den nicht erreichbaren Code konsistent darstellen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 55/100