Skip to content

Calling __new__ via super() #1053

@JukkaL

Description

@JukkaL

Mypy complains about this code, even though it's okay:

class A:
    def __new__(cls, x: int) -> 'A':
        return object.__new__(cls)

class B(A):
    def __new__(cls, x: str) -> 'B':
        return super().__new__(cls, int(x))  # Too many arguments for "__new__" of "A"

print(B('3'))

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions