I am writing type stubs for a proprietary Python platform. The platform often defines classes in some modules and re-export them from other modules. I need my type stubs to reflect that the type exists in more than one file.
For example
_foo.py:
class SomeType:
# Implementation here
foo.py:
from _foo import SomeType
How do I write type stubs for these files?
I have tried this:
_foo.pyi:
class SomeType:
...
foo.pyi:
from _foo import SomeType
But it doesn't work, mypy throws this error:
error: name 'foo.SomeType' is not defined
Is there a way to make this work without copy-pasting the type stub into both files?