Typing and Generics
typing.SupportsRound
Runtime-checkable protocol for objects providing __round__(). A static checker checks the method contract; runtime membership checks only inspect the presence of the required member, not its signature or return type.
Formal Syntax & Structure
python syntaxpython
typing.SupportsRound[int]Return Value
protocol class
Typing construct or runtime result as described; static typing rules are not runtime validation.
Working Example
Example Snippetpython
from typing import SupportsRound
class Value: def __round__(self, ndigits=None): return 3item=Value()print((isinstance(item,SupportsRound), round(item)))