Skip to content

BUG: SupportsComplex doesn't seem to work #4592

Closed
@shoyer

Description

@shoyer

The following snippet triggers a mypy error:

from typing import SupportsComplex

class A(SupportsComplex):
    def __complex__(self) -> complex:
        return 1j

complex(A())
# No overload variant of "complex" matches argument types [test_simple.A]

I believe this is the right way to indicate that a class supports casting to complex values.

I'm using Python 3.6.4 and mypy 0.560. See numpy/numpy-stubs#10 for context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions