Just going to say it one more time and then I’m bowing out, because at this point we’re just talking past each other
int is currently treated as a subtype of float by all type checkers. Regardless of your opinion on that, it is the status quo and changing that is a major backwards compatibility break that would affect millions of lines of code
The Subtype relationships section of PEP 483 gives 3 examples:
Dogis a subtype ofAnimalintis a subtype offloatList[int]is not a subtype ofList[float](becauseListis invariant)
and has this code example
lucky_number = 3.14 # type: float
lucky_number = 42 # Safe
lucky_number * 2 # This works
lucky_number << 5 # Fails
unlucky_number = 13 # type: int
unlucky_number << 5 # This works
unlucky_number = 2.72 # Unsafe
The numeric tower section of PEP 484 says:
PEP 3141 defines Python’s numeric tower, and the stdlib module
numbersimplements the corresponding ABCs (Number,Complex,Real,RationalandIntegral). There are some issues with these ABCs, but the built-in concrete numeric classescomplex,floatandintare ubiquitous (especially the latter two :-).Rather than requiring that users write
import numbersand then usenumbers.Floatetc., this PEP proposes a straightforward shortcut that is almost as effective: when an argument is annotated as having typefloat, an argument of typeintis acceptable; similar, for an argument annotated as having typecomplex, arguments of typefloatorintare acceptable. This does not handle classes implementing the corresponding ABCs or thefractions.Fractionclass, but we believe those use cases are exceedingly rare.
Both assigning an int to a variable annotated as float and passing an int as an argument to a function parameter annotated as float are unambiguously stated as allowed behavior.
The discussion was started here because one of the people working on implementing a type checker correctly pointed out that the current language in the typing specification does not clearly and unambiguously state how allowing those behaviors should be implemented.
Changing what behavior should be allowed is a different topic