Using TypeVar as typing for a function argument disables the --strict-equality check
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
When using a TypeVar as typing for a function parameter, the --strict-equality checks are no longer executed.
To Reproduce
from typing import TypeVar
T = TypeVar("T", int, str)
def a(x: T) -> None:
1 == "a"
def b(x: int | str) -> None:
1 == "a"
a(1)
b(1)
Playground: https://mypy-play.net/?mypy=master&python=3.10&flags=strict&gist=60fa0e9e47a0ed5683357b1fa2611477
Expected Behavior
I would expect both functions a() and b() to raise the comparison-overlap error.
Actual Behavior
Only function b() where there is no TypeVar used raises the comparison-overlap error.
Note that other, standard, mypy checks are executed and flagged in both functions.
Your Environment
- Mypy version used: Checked with multiple (1.4.1, 1.7.0, master branch)
- Mypy command-line flags:
--strictor--strict-equality - Mypy configuration options from
mypy.ini(and other config files): - - Python version used: 3.10, 3.11
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
Esegui il reproducer fornito con --strict-equality e confronta le diagnostiche per le funzioni a() e b(). Traccia la gestione da parte di mypy dei parametri constrained TypeVar; il lavoro è completato quando entrambi i confronti segnalano comparison-overlap e la copertura di regressione conferma il comportamento.
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
- 42/100