8000 Super in a generic classmethod gives error · Issue #9282 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content
Super in a generic classmethod gives error #9282
Closed
@giladsheffer

Description

@giladsheffer
  • Are you reporting a bug, or opening a feature request? Bug
  • Please insert below the code you are checking with mypy,
from typing import TypeVar, Type

T = TypeVar("T", bound="A")

class A:
    @classmethod
    def foo(cls: Type[T]) -> T:
        print(cls.__qualname__)
        return cls()

class B(A):
    @classmethod
    def foo(cls: Type[T]) -> T:
        return super().foo()

B.foo()
  • What is the actual behavior/output?
scratch.py:14: error: Returning Any from function declared to return "T"
scratch.py:14: error: Argument 2 for "super" not an instance of argument 1
  • What are the versions of mypy and Python you are using?
    Python 3.8.5
    mypy 0.790+dev.5e9682143720263466f0aaed1924ccb218160ee0

    Do you see the same issue after installing mypy from Git master? Yes
  • What are the mypy flags you are using? --strict

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0