Closed intentionally-left-nil closed 6 months ago
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅
I have read the CLA Document and I hereby sign the CLA
Couple notes:
__init__.pyi
file instead of the code file because the Async definitions (e.g. SchemaServiceAsyncStub) don't exist in the .py files, but only in the .pyi files. (Maybe there's some IF TYPE_CHECKING magic you could use but I thought this way was straightforward)Client
doesn't have any type hints because of the root problem of typing something that is either sync or async
Fixes #140 This adds mypy type support to the authzed library. The code was almost there already, just needed types for the
__init__.py
The challenge with
__init__.py
is that the Client is either sync or async depending on whether it's in an event loop. Typing this isn't really possible. So, per discord conversation, I broke out two new classes which explicitly are sync or async (and typed those appropriately)Also, I added a new CI job to validate the types in the future
Test plan: Made sure the py.typed file is present: ❯ tar -tf dist/authzed-0.14.0.tar.gz | grep py.typed authzed-0.14.0/authzed/py.typed ❯ unzip -l dist/authzed-0.14.0-py3-none-any.whl | grep py.typed 0 01-01-1980 00:00 authzed/py.typed
Made sure that mypy passes poetry shell mypy authzed
Made an invalid change to the init.pyi file and validated there was a type error Created a CI job to ensure that the types pass as expected.
recheck