Regression with `UnionType` as arg from 1.18.2 to 1.19.0
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
Regression with UnionType from 1.18.2 to 1.19.0, get an error when a union is directly used as an argument typed as UnionType, but not when stored in a variable.
To Reproduce
Playground gist: https://gist.github.com/mypy-play/cd116c86100702e51bc18fe78f0de638
Im below example, foo(example) is fine but foo(int | str) raises an error
from types import UnionType
def foo(t: UnionType) -> None:
pass
example = int | str
foo(example)
foo(int | str)
Expected Behavior
No errors
Actual Behavior
example.py:11: error: Argument 1 to "foo" has incompatible type "UnionType | type[int]"; expected "UnionType" [arg-type]
Your Environment
- Mypy version used: 1.19.0
- Mypy command-line flags: n/a
- Mypy configuration options from
mypy.ini(and other config files):
[mypy]
plugins = pydantic.mypy
ignore_missing_imports = True
disallow_untyped_calls = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
check_untyped_defs = True
warn_unused_ignores = True
warn_no_return = True
warn_return_any = True
warn_redundant_casts = True
strict_equality = True
- Python version used: 3.13.2
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 la riproduzione minima nell’issue o nel playground gist collegato e confronta il suo comportamento con mypy 1.18.2 e 1.19.0. Traccia come viene inferito un argomento int | str diretto rispetto alla variabile example, quindi aggiungi un test di regressione che copra entrambe le chiamate; il lavoro è completato quando mypy non segnala errori per la riproduzione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100