This example app shows how to use generated .pyi files in order to have correct autocomplete and type checking for dynamically loaded thrift interfaces
Stubs were created with command:
thriftpyi example/interfaces --output example/app/interfaces --strict-optional
Note, that __init__.py was created by hand and not by the script. This file is responsible for the actual access to thrift interfaces.
Normally you must do import like this:
from example.app import interfaces
Imports like this will no work:
# DANGER!!! THIS WILL NOT WORK
from example.app.interfaces.todo import Todo
Although, if you still want do import things like shown above you can do it like this:
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from example.app.interfaces.todo import Todo