On this page
typing.SupportsRound
Prev: typing.SupportsInt | Up: typing | Next: typing.Text
Rel: typing.AbstractSet, typing.Annotated, typing.Any, typing.assert_never
Ref: docs.python.org — typing.SupportsRound
Tags: #public #python3 #stdlib #typing
Import
import typing
from typing import SupportsRound
Signature & Overview
typing.SupportsRound(*args, **kwargs)
A protocol with one abstract method round that is covariant in its return type.
Usage
from typing import SupportsRound
assert isinstance(3.14159, SupportsRound) and round(3.14159, 2) == 3.14
Gotchas
- Structural protocol for
__round__(): Matchesfloat,int,Decimal, andFraction.
REPL Inspect
from typing import SupportsRound
help(SupportsRound)
Linked from
Related notes
- tuts/python3/stdlib_module/typing/SupportsInt Linked here; links to this page; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/Text 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