refactor: migrate Python API to websockets asyncio API (>=14.0)#61
Merged
Conversation
Remove the legacy/new websockets API compatibility shim in the iterm2 Python library and migrate directly to the websockets 14.0+ API: - InvalidStatusCode -> InvalidStatus (with response.status_code) - extra_headers -> additional_headers - response_headers -> response.headers - websockets.legacy.client.connect -> websockets.connect - websockets.legacy.client.unix_connect -> websockets.unix_connect - Pin websockets>=14.0 in setup.py Add tests for the connection module covering protocol version parsing, InvalidStatus error handling (406/500/401), async_create error paths, and argument passing to connect methods. This is a compatibility fix for the Tier 1 daemon, which imports the iterm2 Python lib. Adapted from upstream gnachman#607. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Owner
Author
|
Review by tech-lead — APPROVED ✅ (verificado de verdade — lib Python, não o app). Aplicou limpo (3 arquivos, sem conflito). Migração completa p/ a nova API asyncio do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #57
Summary
Imports upstream gnachman#607 ("Migrate Python API to websockets new asyncio API >=14.0") into the fork. This is a compatibility fix for our Tier 1 daemon, which imports the
iterm2Python library. No feature flag — it's an infra/compat change.The change removes the legacy/new websockets API compatibility shim and migrates the
iterm2Python lib directly to the websockets 14.0+ asyncio API:InvalidStatusCode→InvalidStatus(status now read viaresponse.status_code)extra_headers→additional_headersresponse_headers→response.headerswebsockets.legacy.client.connect→websockets.connectwebsockets.legacy.client.unix_connect→websockets.unix_connectwebsockets version change
api/library/python/iterm2/setup.py:install_requirespin changed from'websockets'(unpinned) to'websockets>=14.0'.Files changed
api/library/python/iterm2/iterm2/connection.py— API migrationapi/library/python/iterm2/setup.py— pinwebsockets>=14.0api/library/python/iterm2/tests/test_connection.py— new tests (added by the upstream PR)Test status (honest)
Ran the new
tests/test_connection.pyin an isolated venv (Python 3.11, websockets 15.0, pytest, pytest-asyncio) withPYTHONPATHpointed at the lib: 12 passed (asyncio_mode=auto). The only output noise was unrelated Python enumDeprecationWarnings frommainmenu.py. No app/Xcode build was run — this change is Python-lib-only.Provenance
Adapted from upstream gnachman#607.
Apply notes
Patch applied cleanly onto current
master(no conflicts, no rejects) — these three files are untouched by the fork.🤖 Generated with Claude Code