`mypy --any-exprs-report` depends on formatting
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
The report any-exprs.txt generated by mypy --any-exprs-report changes its output, even if the AST has not changed in any way.
To Reproduce
This is a minimal example:
Error = (
int
| int
)
mypy reports
Name Anys Exprs Coverage
-------------------------------
t 2 4 50.00%
-------------------------------
Total 2 4 50.00%
On the other hand, this example produces no errors
OK = int | int
Again the table, for completeness.
Name Anys Exprs Coverage
-------------------------------
s 0 2 100.00%
-------------------------------
Total 0 2 100.00%
The underlying reason is that mypy counts expressions set as TYPE_UNANALYZED as Anys expression. This is very surprising to me. The specific expression is assigned TYPE_UNANALYZED in StatisticsVisitor.type.
Expected Behavior
The invocation mypy --any-exprs-report matches the number of errors encountered by running mypy --disallow-any-exprs. Or at the very least clear up the documentation:
Causes mypy to generate a text file report documenting how many
expressions of type ``Any`` are present within your codebase.
Your Environment
I don't think this matters, but:
- Mypy version used:
mypy 1.14.0 (compiled: yes)
mypy 1.15.0+dev.d79d89e3ff31ed67a41b0663da9ec8e037d41fa0 (compiled: no) - Mypy command-line flags:
--any-exprs-report - Mypy configuration options from
mypy.ini(and other config files): None - Python version used: 3.12.1
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 dall’implementazione del report any-exprs e dalla posizione StatisticsVisitor.type indicata nel report. Confronta la gestione di TYPE_UNANALYZED in StatisticsVisitor.type con il comportamento di --disallow-any-exprs, quindi controlla la formulazione della documentazione di --any-exprs-report. Il lavoro è completato quando il report non cambia più con una formattazione equivalente oppure quando il comportamento documentato descrive accuratamente ciò che conta.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100