Typing and Generics

typing.SupportsComplex

Runtime-checkable protocol for objects providing __complex__(). 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.SupportsComplex

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 SupportsComplex
class Value:    def __complex__(self): return 2+3jitem=Value()print((isinstance(item,SupportsComplex), complex(item)))
Python Reference