Overload validation does not properly handle implied subtype relationships (e.g. int and float)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia riproducendo i quattro esempi di overload dell’issue e confronta le diagnosi di mypy con la typing specification collegata. Traccia quindi il percorso di validazione di overload responsabile dei controlli di sovrapposizione dei sottotipi, poi verifica che il caso int/float venga diagnosticato in modo coerente con i casi literal, subclass e union.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I'm working to make pyright's overload validation work consistently with mypy's.
Mypy's overload validation behavior is spec'ed here: https://github.com/python/typing/issues/253#issuecomment-389262904
As part of this validation, mypy reports errors when there is overlap between two overloads that return different return types. The following test case shows four such examples. Mypy properly reports the error in three of the four cases, but it misses the case where there is an implied subtype relationship, as between int and float.
# pyright: strict
from typing import Literal, Union, overload
class Parent: ...
class Child(Parent): ...
# Test 1: Literal subtype
@overload
def foo1(x: Literal[3]) -> int: ...
@overload
def foo1(x: int) -> str: ...
# Test 2: Subclass subtype
@overload
def foo2(x: Child) -> str: ...
@overload
def foo2(x: Parent) -> int: ...
# Test 3: Implicit subtype
@overload
def foo3(x: int) -> str: ... # Mypy does not report error here
@overload
def foo3(x: float) -> int: ...
# Test 4: Union subtype
@overload
def foo4(x: int) -> str: ...
@overload
def foo4(x: Union[int, str]) -> int: ...
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Merge medio
- 1g 18h
- PR unite (30g)
- 54
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.
Altre issue di python/mypy
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
bug topic-configuration topic-error-reporting
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Issue simili
-
area/auth bug comp/agent P3 platform/discord type/security
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
NousResearch/hermes-agent#117848 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
bancolombia/sentinel#23 ·
-
test md ApertaCI
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100