Skip to content

Use first super() argument as the target type #3926

Closed

Description

@JukkaL

Currently mypy ignores the type that the first super() argument refers to -- it assumes that it always refers to the enclosing class. This is incorrect. For example, here mypy generates a false negative:

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

class B(A):
    def g(self) -> None:
        super(A, self).f()  # No error though this will fail at runtime

B().g()  # Runtime error

Once we have this, it should be easy to also support the 2-argument form of super() outside class definitions.

This is follow-up to #3919.

Activity

  1. ilevkivskyi commented on Oct 18, 2019

    @ilevkivskyi
    Member

    Now mypy correctly gives an error here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions