On this page
  1. typing.SupportsComplex
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

typing.SupportsComplex

Prev: typing.SupportsBytes | Up: typing | Next: typing.SupportsFloat
Rel: typing.AbstractSet, typing.Annotated, typing.Any, typing.assert_never
Ref: docs.python.org — typing.SupportsComplex
Tags: #public #python3 #stdlib #typing


Import

import typing
from typing import SupportsComplex

Signature & Overview

typing.SupportsComplex(*args, **kwargs)

A protocol with one abstract method complex.

Usage

from typing import SupportsComplex

class Impedance:
    def __complex__(self) -> complex:
        return 1 + 2j

assert isinstance(Impedance(), SupportsComplex)
assert complex(Impedance()) == (1 + 2j)

Gotchas

REPL Inspect

from typing import SupportsComplex
help(SupportsComplex)

Linked from

Related notes