8000 Invalid signature for type object when both __init__ and __new__ · Issue #1435 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Invalid signature for type object when both __init__ and __new__ #1435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

8000

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JukkaL opened this issue Apr 24, 2016 · 0 comments · Fixed by #5642
Closed

Invalid signature for type object when both __init__ and __new__ #1435

JukkaL opened this issue Apr 24, 2016 · 0 comments · Fixed by #5642
Assignees
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-0-high

Comments

@JukkaL
Copy link
Collaborator
JukkaL commented Apr 24, 2016

Mypy complains about the program even though it's valid Python:

class A(object):
    def __init__(self, x):
        pass

class B(A):
    def __new__(cls):
        return 1

B() # Too few arguments for "B"

It seems that mypy uses __init__ and doesn't recognize that __new__ in a subclass should take precedence.

@JukkaL JukkaL added the bug mypy got something wrong label Apr 24, 2016
@gvanrossum gvanrossum added this to the 0.4.x milestone Apr 28, 2016
@gvanrossum gvanrossum removed this from the 0.4.x milestone Mar 29, 2017
@ilevkivskyi ilevkivskyi added the false-positive mypy gave an error on correct code label Aug 26, 2018
@
9A56
msullivan msullivan self-assigned this Sep 19, 2018
msullivan added a commit that referenced this issue Sep 19, 2018
Currently mypy will prefer __init__ to __new__ for determining
the signature of a type object if there exists any __init__
other than object's.
Instead, prefer the closest definition in the MRO, so that
subclass __new__ can override parent __init__.

Fixes #1435.
msullivan added a commit that referenced this issue Sep 20, 2018
Currently mypy will prefer __init__ to __new__ for determining
the signature of a type object if there exists any __init__
other than object's.
Instead, prefer the closest definition in the MRO, so that
subclass __new__ can override parent __init__.

Fixes #1435.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-0-high
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
0