[red-knot] how should assert_type
handle the float/complex special case?
#16171
Labels
red-knot
Multi-file analysis & type inference
Description
We follow the typing spec and other type checkers in implementing the special case that a
float
annotation meansint | float
, and acomplex
annotation meansint | float | complex
.We don't currently follow other type checkers in trying to "hide" this special case by revealing just
float
orcomplex
when the actual type we have isint | float
orint | float | complex
. Doing this leads to very strange-looking behaviors, like this from pyright:But this leads us to fail this type assertion:
Because we interpret
float
there as a type expression, meaning we take it to beint | float
, but we actually infer justfloat
for the literal.The text was updated successfully, but these errors were encountered: