pgjones / hypercorn

Hypercorn is an ASGI and WSGI Server based on Hyper libraries and inspired by Gunicorn.
MIT License
1.12k stars 102 forks source link

Improve typing against Trio #239

Closed jakkdl closed 3 months ago

jakkdl commented 3 months ago

After changes to typing in upstream trio, end users have been getting typing errors due to the type on TaskStatus. This would've been caught if the mypy test environment had trio as a dependency. So this PR fixes those type errors, updates tox & mypy configs to check against trio, and adds/updates/fixes lots of other minor annotations.

This also caught a presumed typo in "lifspan.startup.complete" missing an "e" in a test.

It doesn't seem great that this project is maintaining its own set of types for the ASGI reference, I've discussed this a bit in https://github.com/django/asgiref/issues/460. If you're up for it I'd love to throw out src/hypercorn/typing.py and replace it with a dependency on the asgi-types package (after updating it).

Hopefully h11 will push a release so the ~dozen of type errors introduced by that can be ignored: https://github.com/python-hyper/h11/issues/175

pgjones commented 3 months ago

Thanks, I've merged manually with a few tweaks in 84d06b8cf47798d2df7722273341e720ec0ea102

...replace it with a dependency on the asgi-types package...

I don't wish to add any more dependencies for Hypercorn. I do intend to update Hypercorn's types when I review the ASGI spec (hence why I've removed the changes for now).

Hopefully h11 will push a release...

I will get to h11 soon, I should now have enough access to make the hyper projects easier to maintain.