具有以下代码:
class Base: pass
def factory():
return type("A", (Base,), {})
factory
函数返回类型的正确注释是什么?如果我这样做:
def factory() -> Type[Base]:
return type("A", (Base,), {}) # Here the type checker complains:
# Expected type Type[Base], got 'type' instead.