mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
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:
parent
a23cb72ac8
commit
3e46f9fe05
5 changed files with 45 additions and 1 deletions
|
|
@ -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
|
||||
---------------------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue