The authzed library already ships with most of the necessary type hints in *.pyi files. However, mypy can't use this because:
There's no py.typed file in the package so these types can't be used at all
Even if the file were there, there's no types for __init__.py
In __init__.py the type for the Client is wrong/ really hard to implement because it could either be the Async* versions or the Sync versions
E.g. depending on whether you're in an async loop, the correct definition is either
class Client(SchemaServiceStub, PermissionsServiceStub, ExperimentalServiceStub, WatchServiceStub):
...
OR
class Client(SchemaServiceAsyncStub, PermissionsServiceAsyncStub, ExperimentalServiceAsyncStub, WatchServiceAsyncStub):
...
So, largely we need to solve the __init__.py file before we can continue. I have one concrete suggestion: Make a separate AsyncClient which has the latter type signature. Then, make a new SyncClient which is just an alias to the existing Client. That will allow the type hints to be straightforward.
Then, if we add the type hints directly to the __init__.py file for the init method, we wouldn't need a separate __init__.pyi file since the init file would have all of the necessary type hints
The authzed library already ships with most of the necessary type hints in
*.pyi
files. However, mypy can't use this because:py.typed
file in the package so these types can't be used at all__init__.py
__init__.py
the type for the Client is wrong/ really hard to implement because it could either be the Async* versions or the Sync versionsE.g. depending on whether you're in an async loop, the correct definition is either
OR
So, largely we need to solve the
__init__.py
file before we can continue. I have one concrete suggestion: Make a separateAsyncClient
which has the latter type signature. Then, make a newSyncClient
which is just an alias to the existing Client. That will allow the type hints to be straightforward.Then, if we add the type hints directly to the
__init__.py
file for the init method, we wouldn't need a separate__init__.pyi
file since the init file would have all of the necessary type hints