Skip to content

Add missing wsproto dependency and twisted extra - #44

Open
azhar22k wants to merge 2 commits into
localstack:mainfrom
azhar22k:fix-unlisted-wsproto-dependency
Open

azhar22k wants to merge 2 commits into
localstack:mainfrom
azhar22k:fix-unlisted-wsproto-dependency

Conversation

@azhar22k

@azhar22k azhar22k commented Sep 26, 2026 •

Copy link
Copy Markdown

Motivation

Fixes #28.

When using rolo with twisted without hypercorn installed (such as in minimal installations or in downstream projects that only use the Twisted runtime), importing rolo.serving.twisted fails with:

File ".../rolo/serving/twisted.py", line 21, in <module>
    from wsproto import ConnectionType, WSConnection, events
ModuleNotFoundError: No module named 'wsproto'

rolo.serving.twisted (and rolo.testing.pytest) requires wsproto for WebSocket framing and protocol handling over Twisted. However, wsproto was not declared in pyproject.toml, and only worked in development because hypercorn transitively pulled it in.

Changes

  • Added wsproto>=1.0.0 to dependencies in pyproject.toml.
  • Added twisted = ["twisted>=24"] and hypercorn = ["hypercorn"] optional dependency extras in pyproject.toml.
  • Added a test in tests/serving/test_twisted.py verifying wsproto and TwistedGateway importability.

Testing

  • Verified reproduction in a clean virtual environment: pip install -e . && pip install twisted previously raised ModuleNotFoundError: No module named 'wsproto' when importing TwistedGateway, and now succeeds cleanly.
  • Ran full test suite (make test): all 169 tests pass.
  • Formatted and verified with make format and make lint.

@azhar22k
azhar22k requested a review from bentsku as a code owner September 26, 2026 16:01

@bentsku bentsku left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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():

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@azhar22k
azhar22k requested a review from bentsku September 29, 2026 16:26

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unlisted dependency: wsproto

2 participants