gh-100268: Add is_integer method to int (#100439)

This improves the lives of type annotation users of `float` - which type checkers implicitly treat as `int|float` because that is what most code actually wants. Before this change a `.is_integer()` method could not be assumed to exist on things annotated as `: float` due to the method not existing on both types.
This commit is contained in:
Shantanu 2022-12-23 20:30:27 -06:00 committed by GitHub
parent a23cb72ac8
commit 3e46f9fe05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 1 deletions

View file

@ -609,6 +609,12 @@ class`. In addition, it provides a few more methods:
.. versionadded:: 3.8
.. method:: int.is_integer()
Returns ``True``. Exists for duck type compatibility with :meth:`float.is_integer`.
.. versionadded:: 3.12
Additional Methods on Float
---------------------------