mypy does not enforce lack of template argument

Viewed 50

I have a virtual templated super class I inherit from. I forgot to specify the template argument in one of its subclasses, and was very surprised to find out that mypy did not issue any warning about that:

from abc import ABC, abstractmethod
from typing import Generic, TypeVar
Data = TypeVar("Data")
class SomeTemplatedClass(ABC, Generic[Data]):
    def __init__(self) -> None:
        self.i = 900

    @abstractmethod
    def run(self, d: Data) -> int:
        ...

class ConcreteClass(SomeTemplatedClass): <----- should be SomeTemplatedClass[int]
    def __init__(self):
        self.s = "moish"

    def run(self, d: int) -> int:
        return self.i + d + 600

c = ConcreteClass()

I'm using a recent mypy version, what am I missing?

$ mypy --version
0.812
$ mypy example.py
Success: no issues found in 1 source file
0 Answers
Related