Skip to content

Wrong unsoundness? #1330

@AntoineD

Description

@AntoineD

The following reproducer code returns the __init__ method of a class:

from typing import Any
def f(cls: type) -> Any:
    return cls.__init__

but mypy considers that the __init__method was accessed from an instance:
main.py:4: error: Accessing "__init__" on an instance is unsound, since instance.__init__ could be from an incompatible subclass [misc]

Where is the problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: otherOther topics not covered

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions