Skip to content

super().__init__ doesn't work in explicit protocol subclasses #572

@ilevkivskyi

Description

@ilevkivskyi

A possible solution is to append a call to existing __init__ while overwriting (after the check for _is_protocol=True, where we unconditionally raise because protocols can't be instantiated). This way explicit non-protocol subclasses can use a protocol __init__ as a "default constructor". Default implementations are already supported for other protocol members, so it is natural to expect that __init__ is not different. See also python/mypy#3823

cc: @JukkaL

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