diff options
author | Shantanu <12621235+hauntsaninja@users.noreply.github.com> | 2022-12-24 02:30:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-24 02:30:27 (GMT) |
commit | 3e46f9fe05b40ee42009878620f448d3a4b44cb5 (patch) | |
tree | 73a990d85dd392b93303c8fe98276029eef15f5b /Doc | |
parent | a23cb72ac82372fac05ba36ce08923840ca0de06 (diff) | |
download | cpython-3e46f9fe05b40ee42009878620f448d3a4b44cb5.zip cpython-3e46f9fe05b40ee42009878620f448d3a4b44cb5.tar.gz cpython-3e46f9fe05b40ee42009878620f448d3a4b44cb5.tar.bz2 |
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.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/stdtypes.rst | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 624284f..0ef0303 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -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 --------------------------- |