typing icon indicating copy to clipboard operation
typing copied to clipboard

Proposed clarification of spec for int/float/complex promotion

Open JelleZijlstra opened this issue 1 year ago • 3 comments

Fixes #1746.

JelleZijlstra avatar May 23 '24 05:05 JelleZijlstra

There's also a case that should have an explicit ruling with overload compatability, shown here: https://discuss.python.org/t/clarifying-the-float-int-complex-special-case/54018/44 as the changes do have other effects that break existing cases.

DiscordLiz avatar Jun 29 '25 22:06 DiscordLiz

I'm still in the process of figuring out the implications to mypy (which uses a differerent approach currently), in case this would surface some additional edge cases worth documenting. I'm generally positive about clarifying the spec here though.

JukkaL avatar Jul 03 '25 16:07 JukkaL

Yes, this approach would imply changes to how mypy currently implements the special case. An alternative could be to specify mypy's behavior (which is essentially to pretend that int is a subclass of float), but I think that behavior is harder to understand and harder to specify precisely.

JelleZijlstra avatar Jul 03 '25 16:07 JelleZijlstra