On this page
typing.SupportsInt
Prev: typing.SupportsIndex | Up: typing | Next: typing.SupportsRound
Rel: typing.AbstractSet, typing.Annotated, typing.Any, typing.assert_never
Ref: docs.python.org — typing.SupportsInt
Tags: #public #python3 #stdlib #typing
Import
import typing
from typing import SupportsInt
Signature & Overview
typing.SupportsInt(*args, **kwargs)
A protocol with one abstract method int.
Usage
from typing import SupportsInt
assert isinstance(3.9, SupportsInt) and int(3.9) == 3
Gotchas
- Matches objects implementing
__int__(): Includesfloat, so useSupportsIndexwhen you want exact integer indices only.
REPL Inspect
from typing import SupportsInt
help(SupportsInt)
Linked from
Related notes
- tuts/python3/stdlib_module/typing/SupportsIndex Linked here; links to this page; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/SupportsRound Linked here; links to this page; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/typing/AbstractSet Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/Annotated Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/Any Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/assert_never Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/assert_type shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/AsyncContextManager shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/AsyncGenerator shared tags: #stdlib, #typing