I have something similar to this:
from typing import Type
class Foo:
pass
def make_a_foobar_class(foo_class: Type[Foo]) -> Type[Foo]:
class FooBar(foo_class):
# this.py:10: error: Variable "foo_class" is not valid as a type
# this.py:10: error: Invalid base class "foo_class"
pass
return FooBar
print(make_a_foobar_class(Foo)())
Running mypy
throws these two errors (added as comments ^) at line class FooBar(foo_class):
The code seems to work just fine:
$ python this.py
<__main__.make_a_foobar_class.<locals>.FooBar object at 0x10a422be0>
What am I doing wrong?