Skip to content
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.

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

Doesn't recognize all uses of super #857

Open
agentydragon opened this issue Aug 21, 2015 · 4 comments
Open

Doesn't recognize all uses of super #857

agentydragon opened this issue Aug 21, 2015 · 4 comments
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-1-normal

Comments

@agentydragon
Copy link
Contributor

class A:
    def __init__(self, a): pass
class B(A):
    def __init__(self, a):
        super(B, self).__init__(a)
        self._inner = super(B, self)

Yields: test.py:6: error: Name 'super' is not defined

@JukkaL JukkaL added bug mypy got something wrong hack and removed hack labels Aug 21, 2015
@JukkaL JukkaL closed this as completed in d30137c Nov 26, 2015
@JukkaL
Copy link
Collaborator

JukkaL commented Nov 26, 2015

Sorry, closed the wrong issue.

@JukkaL JukkaL reopened this Nov 26, 2015
@ddfisher ddfisher added this to the 0.3.3 milestone Mar 2, 2016
@gnprice gnprice removed the priority label Mar 2, 2016
@gvanrossum gvanrossum modified the milestones: 0.3.2, 0.3.3 Mar 17, 2016
@JukkaL JukkaL modified the milestones: 0.4.0, 0.3.2 Mar 17, 2016
@JukkaL
Copy link
Collaborator

JukkaL commented Mar 17, 2016

Moved to 0.4.0 as this doesn't seem very frequent in real-world code.

@JordanP
Copy link

JordanP commented Oct 22, 2016

I came across this bug today. I agree that this doesn't seem frequent in real-world code. An example of this usage of super here: https://github.com/dabeaz/python-cookbook/blob/8a71861a81350e55bd77556996ac3b530a1ffe5e/src/9/enforcing_coding_conventions_in_classes/example2.py#L9

@gvanrossum gvanrossum removed this from the 0.5 milestone Mar 29, 2017
@JukkaL
Copy link
Collaborator

JukkaL commented May 18, 2018

This an updated example that reproduces the issue:

class A:
    def f(self) -> None: pass

class B(A):
    def __init__(self) -> None:
        s = super(B, self)
        s.f()  # "super" has no attribute "f"

@JukkaL JukkaL added the false-positive mypy gave an error on correct code label May 18, 2018
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-1-normal
Projects
None yet
Development

No branches or pull requests

6 participants