Conversation
bentsku
left a comment
There was a problem hiding this comment.
Thanks for the contribution! I think this is a proper fix, I'm not sure about adding wsproto in both regular dependencies and the dev dependencies though? Is there a specific reason to do that?
Also, the new twisted extra is good, but it's only for twisted and not hypercorn?
I feel this problem might be fixed if we were to setup something like deptry instead, which would catch these missing dependencies as they're imported. If you want to try to add deptry to the repo (with , you're welcome to do it, otherwise you can tell me and I'll go ahead. I'm afraid it's a bit more work, like adding a new lint step, etc.
| assert response_data["raw_uri"].startswith("http") | ||
|
|
||
|
|
||
| def test_twisted_gateway_import_and_wsproto_dependency(): |
There was a problem hiding this comment.
note: I don't think this test adds anything, as in the regular test environment, all dependencies will be installed. I don't think it prevents any regression?
There was a problem hiding this comment.
Thanks for the review @bentsku!
- wsproto in dev: You're completely right - having wsproto in dev was redundant since it's already included under regular dependencies (which are installed when installing the dev extra). I've removed it from dev.
- hypercorn extra: Added hypercorn = ["hypercorn"] under [project.optional-dependencies] alongside twisted.
- deptry: Setting up deptry would be a great addition to the repo to catch these automatically! Since it involves configuring rules for dev dependencies, transitive packages, and adding a new CI lint step, it would probably be cleanest as a separate PR/follow-up. Please feel free to go ahead with that!
Pushed the updates.
Motivation
Fixes #28.
When using
rolowithtwistedwithouthypercorninstalled (such as in minimal installations or in downstream projects that only use the Twisted runtime), importingrolo.serving.twistedfails with:rolo.serving.twisted(androlo.testing.pytest) requireswsprotofor WebSocket framing and protocol handling over Twisted. However,wsprotowas not declared inpyproject.toml, and only worked in development becausehypercorntransitively pulled it in.Changes
wsproto>=1.0.0todependenciesinpyproject.toml.twisted = ["twisted>=24"]andhypercorn = ["hypercorn"]optional dependency extras inpyproject.toml.tests/serving/test_twisted.pyverifyingwsprotoandTwistedGatewayimportability.Testing
pip install -e . && pip install twistedpreviously raisedModuleNotFoundError: No module named 'wsproto'when importingTwistedGateway, and now succeeds cleanly.make test): all 169 tests pass.make formatandmake lint.