discrepencay between mypy and mypyc
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
Bug Report
Code passes according to mypy but fails with mypyc.
To Reproduce
from pathlib import Path
from typing import TypeVar
PathNoneT = TypeVar("PathNoneT", Path, None)
def return_value(path: PathNoneT) -> PathNoneT:
if path is None:
return path
new_path = path.with_suffix(".test")
if not new_path.is_file() and path.is_file():
new_path = path
# mypyc: error: Incompatible return value type (got "Union[Path, Any]", expected "PathNoneT") [return-value]
return new_path
Expected Behavior
mypyc emits exactly the same errors as mypy.
Actual Behavior
Mypyc reports error: Incompatible return value type (got "Union[Path, Any]", expected "PathNoneT") [return-value] .
Your Environment
- Mypy version used: 0.991
- Python version used: 3.10.8
- Mypy configuration options from
mypy.ini(and other config files):
show_error_codes = true
enable_error_code = "ignore-without-code"
follow_imports = "silent"
warn_unused_configs = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_no_return = true
no_implicit_optional = true
check_untyped_defs = true
disallow_incomplete_defs = true
disallow_untyped_defs = true
disallow_untyped_decorators = true
strict_equality = truedisallow_any_generics = false
ignore_missing_imports = true
warn_return_any = false
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 riproducendo l'esempio generico Path fornito con Python 3.10.8 e confronta il risultato di mypy con la diagnostica di mypyc. Traccia il percorso di controllo dei tipi responsabile dell'errore return-value differente; il lavoro è completato quando mypyc emette gli stessi errori di mypy per questo esempio.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100