ty
ty copied to clipboard
Built-in operators on `JustFloat`s should return `JustFloat`.
Summary
(Based on https://github.com/astral-sh/ty/issues/2184#issuecomment-3697621323)
Ty reports the sum of two JustFloat values is int | float. I would have expected it to be another JustFloat, given that result is always a float at runtime.
a = 0.1
b = 0.2
reveal_type(a) # float
reveal_type(b) # float
c = a + b
reveal_type(c) # int | float
https://play.ty.dev/a7945e32-cb7d-4765-bf50-d3b2b711b6ed
Version
ty 0.0.8 (aa7559db8 2025-12-29)
Thanks for reporting this! Barring a change to typeshed (or a change in our handling of float annotations generally) we would need to special-case methods known to return just-float (or patch our copy of typeshed.)