dependent-type

Dependent types and polymorphism in Python with mypy

Dependent types and polymorphism in Python with mypy Question: For the following example, mypy returns an error: error: Incompatible types in assignment (expression has type “A”, variable has type “A1”) from typing import Type class A: pass class A1(A): pass class A2(A): pass def fun(A_type: Type[A]) -> A: if A_type == A1: return A1() else: …

Total answers: 2