tus / tus-py-client

A Python client for the tus resumable upload protocol
https://tus.io/
MIT License
167 stars 45 forks source link

Expose typing information (PEP 561) #88

Closed nhairs closed 10 months ago

nhairs commented 10 months ago

This allows external projects that use type checkers themselves to read the typing information that tus-py-client contains.

Without this file, compliant type-checkers will skip type checks for project code that calls tus-py-client.

Fixes #87

Note: this PR should be backwards compatible to pretty much any branch, so if there are more versions maintained than just master branch, applying the same patch to them would allow older versions to type check without upgrading to the latest version of tus-py-client.

Test Plan

  1. Create test file example.py:
    
    import tusclient.uploader

foo = tusclient.uploader.Uploader(False)


2. Run MyPy `mypy example.py`
    Should observe MyPy `import` error.
3. Build new version of tus-py-client `python3 -m build`
4. Install new version of tus-py-client `pip install ./path/to/tus-py-client/dist/tuspy-1.0.2-py3-none-any.whl`
5. Re-run MyPy (step 3)
    Observe MyPy `arg-type` error.
nhairs commented 10 months ago

I've made this as two separate commits so there is other work that should be released with this version we can just cherry pick 4467bde. Alternatively if everything is good to go you should be able to do a rebase or squash commit.