Typing and Generics
typing.SupportsAbs
Runtime-checkable protocol for objects providing __abs__(). 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.SupportsAbs[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 SupportsAbs
class Value: def __abs__(self): return 4item=Value()print((isinstance(item,SupportsAbs), abs(item)))