error: Expression is of type "Any", not "Any" (Using `Any` as a `type`)
Aperta
Nessuno ha ancora preso questa issue.
bug
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Here is a minimum reproducible example of this bug:
from typing import Any, assert_type
def foo[T](typ: type[T]) -> T: ...
assert_type(foo(Any), Any)
reveal_type(foo(Any), Any)
reveal_type(Any)
which produces this output:
error: Expression is of type "Any", not "Any" [assert-type]
note: Revealed type is "typing.Any"
note: Revealed type is "def () -> typing.Any"
I did not expect this to cause any mypy errors.
Or, it would say that Any is not a type.
Your Environment
- Mypy version used: mypy 1.19.1 (compiled: yes)
- Mypy command-line flags: NA
- Mypy configuration options from
mypy.ini(and other config files): NA - Python version used: 3.13.9 (also reproduced in 3.14.3)
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
Non viene indicato alcun file del repository né alcun test. Inizia eseguendo il reproducer fornito con mypy 1.19.1, quindi traccia come viene gestito Any quando viene passato a type[T] e da assert_type; il lavoro è completato quando l’esempio non produce alcun errore assert-type errato e mantiene i tipi rivelati.
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
- 35/100