Globally replace all instances of float with FloatInt and of complex with ComplexInt in the stdlib.
After 2026-09-22 we do the same for third-party stubs.
Review FloatInt and ComplexInt instances are replace them with the proper types. (This will take a while.)
Remove the type aliases once they are not needed anymore (in 10 years or so ...)
Using FloatInt and ComplexInt would be disallowed for new code and the type aliases should explicitly be marked as not to be used by non-typeshed code.
We should also probably add flake8-pyi checks that checks that argument types use float | int and complex | float | int. Cases where only float/complex is allowed are probably rare.
Should we also add a JustFloat = float alias to _typeshed to explicitly mark places where we really do only want float? I suspect that's not uncommon in return types.
Should we also add a JustFloat = float alias to _typeshed to explicitly mark places where we really do only want float? I suspect that's not uncommon in return types.
With the plan above (which was incomplete before), we shouldn't need that. A plain float means just that. Please note that step 2-4 basically replace all floats in typeshed, until they are fixed to be either float or int | float.
But until we have replaced them all, we don't know whether float means "exactly float" or float | int. Having an explicit replacement means we can safely look for remaining float usages and know they should all be replaced.
After the steps "Globally replace all instances of float with FloatInt and of complex with ComplexInt" there shouldn't any bare float instances be left. I think doing it this way around (starting with lots of FloatInts and then slowly reducing them) is better than the alternative (starting without any type aliases and then increasing them until all floats are replaced and then removing them again).
#16068 introduces the type aliases. Globally replacing the types requires a bit more work, but the earlier we get the type aliases into typeshed, the earlier we can use them for third-party packages.
Activity
JelleZijlstra commented on Jul 21, 2026
Should we also add a JustFloat = float alias to _typeshed to explicitly mark places where we really do only want float? I suspect that's not uncommon in return types.
srittau commented on Jul 21, 2026
With the plan above (which was incomplete before), we shouldn't need that. A plain float means just that. Please note that step 2-4 basically replace all floats in typeshed, until they are fixed to be either float or int | float.
JelleZijlstra commented on Jul 21, 2026
But until we have replaced them all, we don't know whether float means "exactly float" or float | int. Having an explicit replacement means we can safely look for remaining float usages and know they should all be replaced.
srittau commented on Jul 21, 2026
After the steps "Globally replace all instances of float with FloatInt and of complex with ComplexInt" there shouldn't any bare float instances be left. I think doing it this way around (starting with lots of FloatInts and then slowly reducing them) is better than the alternative (starting without any type aliases and then increasing them until all floats are replaced and then removing them again).
srittau commented on Jul 22, 2026
#16068 introduces the type aliases. Globally replacing the types requires a bit more work, but the earlier we get the type aliases into typeshed, the earlier we can use them for third-party packages.
Ignore flake8-pyi Y041 (redundant float | int) (#16096)