Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update websockets #357

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,5 @@ dmypy.json

# System files
.DS_Store

.idea
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
)

try:
from websockets.client import ( # type: ignore[import-not-found,unused-ignore]
WebSocketClientProtocol,
from websockets import ( # type: ignore[import-not-found,unused-ignore]
ClientConnection,
)
from websockets.client import (
from websockets import (
connect as ws_connect,
)
from websockets.typing import ( # type: ignore[import-not-found,unused-ignore]
Expand All @@ -35,7 +35,7 @@ async def ws_connect(*args, **kwargs):
raise NotImplementedError("Subscriptions require 'websockets' package.")
yield

WebSocketClientProtocol = Any # type: ignore[misc,assignment,unused-ignore]
ClientConnection = Any # type: ignore[misc,assignment,unused-ignore]
Data = Any # type: ignore[misc,assignment,unused-ignore]
Origin = Any # type: ignore[misc,assignment,unused-ignore]

Expand Down Expand Up @@ -304,7 +304,7 @@ async def _execute_json(
**merged_kwargs,
)

async def _send_connection_init(self, websocket: WebSocketClientProtocol) -> None:
async def _send_connection_init(self, websocket: ClientConnection) -> None:
payload: Dict[str, Any] = {
"type": GraphQLTransportWSMessageType.CONNECTION_INIT.value
}
Expand All @@ -314,7 +314,7 @@ async def _send_connection_init(self, websocket: WebSocketClientProtocol) -> Non

async def _send_subscribe(
self,
websocket: WebSocketClientProtocol,
websocket: ClientConnection,
operation_id: str,
query: str,
operation_name: Optional[str] = None,
Expand All @@ -334,7 +334,7 @@ async def _send_subscribe(
async def _handle_ws_message(
self,
message: Data,
websocket: WebSocketClientProtocol,
websocket: ClientConnection,
expected_type: Optional[GraphQLTransportWSMessageType] = None,
) -> Optional[Dict[str, Any]]:
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
)

try:
from websockets.client import ( # type: ignore[import-not-found,unused-ignore]
WebSocketClientProtocol,
from websockets import ( # type: ignore[import-not-found,unused-ignore]
ClientConnection,
)
from websockets.client import (
from websockets import (
connect as ws_connect,
)
from websockets.typing import ( # type: ignore[import-not-found,unused-ignore]
Expand All @@ -46,7 +46,7 @@ async def ws_connect(*args, **kwargs):
raise NotImplementedError("Subscriptions require 'websockets' package.")
yield

WebSocketClientProtocol = Any # type: ignore[misc,assignment,unused-ignore]
ClientConnection = Any # type: ignore[misc,assignment,unused-ignore]
Data = Any # type: ignore[misc,assignment,unused-ignore]
Origin = Any # type: ignore[misc,assignment,unused-ignore]

Expand Down Expand Up @@ -394,7 +394,7 @@ async def _execute_ws(
if data:
yield data

async def _send_connection_init(self, websocket: WebSocketClientProtocol) -> None:
async def _send_connection_init(self, websocket: ClientConnection) -> None:
payload: Dict[str, Any] = {
"type": GraphQLTransportWSMessageType.CONNECTION_INIT.value
}
Expand All @@ -404,7 +404,7 @@ async def _send_connection_init(self, websocket: WebSocketClientProtocol) -> Non

async def _send_subscribe(
self,
websocket: WebSocketClientProtocol,
websocket: ClientConnection,
operation_id: str,
query: str,
operation_name: Optional[str] = None,
Expand All @@ -424,7 +424,7 @@ async def _send_subscribe(
async def _handle_ws_message(
self,
message: Data,
websocket: WebSocketClientProtocol,
websocket: ClientConnection,
expected_type: Optional[GraphQLTransportWSMessageType] = None,
) -> Optional[Dict[str, Any]]:
try:
Expand Down Expand Up @@ -603,7 +603,7 @@ async def _execute_ws_with_telemetry(
yield data

async def _send_connection_init_with_telemetry(
self, root_span: Span, websocket: WebSocketClientProtocol
self, root_span: Span, websocket: ClientConnection
) -> None:
with self.tracer.start_as_current_span( # type: ignore
"connection init", context=set_span_in_context(root_span)
Expand All @@ -622,7 +622,7 @@ async def _send_connection_init_with_telemetry(
async def _send_subscribe_with_telemetry(
self,
root_span: Span,
websocket: WebSocketClientProtocol,
websocket: ClientConnection,
operation_id: str,
query: str,
operation_name: Optional[str] = None,
Expand Down Expand Up @@ -654,7 +654,7 @@ async def _handle_ws_message_with_telemetry(
self,
root_span: Span,
message: Data,
websocket: WebSocketClientProtocol,
websocket: ClientConnection,
expected_type: Optional[GraphQLTransportWSMessageType] = None,
) -> Optional[Dict[str, Any]]:
with self.tracer.start_as_current_span( # type: ignore
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ test = [
"pytest-mock",
"requests-toolbelt",
"types-toml",
"websockets~=11.0",
"websockets>=14.2",
"opentelemetry-api",
]
types = ["mypy>=1.0.0"]
subscriptions = ["websockets~=11.0"]
subscriptions = ["websockets>=14.2"]
opentelemetry = ["opentelemetry-api"]

[project.scripts]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
)

try:
from websockets.client import ( # type: ignore[import-not-found,unused-ignore]
WebSocketClientProtocol,
from websockets import ( # type: ignore[import-not-found,unused-ignore]
ClientConnection,
)
from websockets.client import (
from websockets import (
connect as ws_connect,
)
from websockets.typing import ( # type: ignore[import-not-found,unused-ignore]
Expand All @@ -35,7 +35,7 @@ async def ws_connect(*args, **kwargs):
raise NotImplementedError("Subscriptions require 'websockets' package.")
yield

WebSocketClientProtocol = Any # type: ignore[misc,assignment,unused-ignore]
ClientConnection = Any # type: ignore[misc,assignment,unused-ignore]
Data = Any # type: ignore[misc,assignment,unused-ignore]
Origin = Any # type: ignore[misc,assignment,unused-ignore]

Expand Down Expand Up @@ -304,7 +304,7 @@ async def _execute_json(
**merged_kwargs,
)

async def _send_connection_init(self, websocket: WebSocketClientProtocol) -> None:
async def _send_connection_init(self, websocket: ClientConnection) -> None:
payload: Dict[str, Any] = {
"type": GraphQLTransportWSMessageType.CONNECTION_INIT.value
}
Expand All @@ -314,7 +314,7 @@ async def _send_connection_init(self, websocket: WebSocketClientProtocol) -> Non

async def _send_subscribe(
self,
websocket: WebSocketClientProtocol,
websocket: ClientConnection,
operation_id: str,
query: str,
operation_name: Optional[str] = None,
Expand All @@ -334,7 +334,7 @@ async def _send_subscribe(
async def _handle_ws_message(
self,
message: Data,
websocket: WebSocketClientProtocol,
websocket: ClientConnection,
expected_type: Optional[GraphQLTransportWSMessageType] = None,
) -> Optional[Dict[str, Any]]:
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
)

try:
from websockets.client import ( # type: ignore[import-not-found,unused-ignore]
WebSocketClientProtocol,
from websockets import ( # type: ignore[import-not-found,unused-ignore]
ClientConnection,
)
from websockets.client import (
from websockets import (
connect as ws_connect,
)
from websockets.typing import ( # type: ignore[import-not-found,unused-ignore]
Expand All @@ -35,7 +35,7 @@ async def ws_connect(*args, **kwargs):
raise NotImplementedError("Subscriptions require 'websockets' package.")
yield

WebSocketClientProtocol = Any # type: ignore[misc,assignment,unused-ignore]
ClientConnection = Any # type: ignore[misc,assignment,unused-ignore]
Data = Any # type: ignore[misc,assignment,unused-ignore]
Origin = Any # type: ignore[misc,assignment,unused-ignore]

Expand Down Expand Up @@ -304,7 +304,7 @@ async def _execute_json(
**merged_kwargs,
)

async def _send_connection_init(self, websocket: WebSocketClientProtocol) -> None:
async def _send_connection_init(self, websocket: ClientConnection) -> None:
payload: Dict[str, Any] = {
"type": GraphQLTransportWSMessageType.CONNECTION_INIT.value
}
Expand All @@ -314,7 +314,7 @@ async def _send_connection_init(self, websocket: WebSocketClientProtocol) -> Non

async def _send_subscribe(
self,
websocket: WebSocketClientProtocol,
websocket: ClientConnection,
operation_id: str,
query: str,
operation_name: Optional[str] = None,
Expand All @@ -334,7 +334,7 @@ async def _send_subscribe(
async def _handle_ws_message(
self,
message: Data,
websocket: WebSocketClientProtocol,
websocket: ClientConnection,
expected_type: Optional[GraphQLTransportWSMessageType] = None,
) -> Optional[Dict[str, Any]]:
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
)

try:
from websockets.client import ( # type: ignore[import-not-found,unused-ignore]
WebSocketClientProtocol,
from websockets import ( # type: ignore[import-not-found,unused-ignore]
ClientConnection,
)
from websockets.client import (
from websockets import (
connect as ws_connect,
)
from websockets.typing import ( # type: ignore[import-not-found,unused-ignore]
Expand All @@ -35,7 +35,7 @@ async def ws_connect(*args, **kwargs):
raise NotImplementedError("Subscriptions require 'websockets' package.")
yield

WebSocketClientProtocol = Any # type: ignore[misc,assignment,unused-ignore]
ClientConnection = Any # type: ignore[misc,assignment,unused-ignore]
Data = Any # type: ignore[misc,assignment,unused-ignore]
Origin = Any # type: ignore[misc,assignment,unused-ignore]

Expand Down Expand Up @@ -304,7 +304,7 @@ async def _execute_json(
**merged_kwargs,
)

async def _send_connection_init(self, websocket: WebSocketClientProtocol) -> None:
async def _send_connection_init(self, websocket: ClientConnection) -> None:
payload: Dict[str, Any] = {
"type": GraphQLTransportWSMessageType.CONNECTION_INIT.value
}
Expand All @@ -314,7 +314,7 @@ async def _send_connection_init(self, websocket: WebSocketClientProtocol) -> Non

async def _send_subscribe(
self,
websocket: WebSocketClientProtocol,
websocket: ClientConnection,
operation_id: str,
query: str,
operation_name: Optional[str] = None,
Expand All @@ -334,7 +334,7 @@ async def _send_subscribe(
async def _handle_ws_message(
self,
message: Data,
websocket: WebSocketClientProtocol,
websocket: ClientConnection,
expected_type: Optional[GraphQLTransportWSMessageType] = None,
) -> Optional[Dict[str, Any]]:
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
)

try:
from websockets.client import ( # type: ignore[import-not-found,unused-ignore]
WebSocketClientProtocol,
from websockets import ( # type: ignore[import-not-found,unused-ignore]
ClientConnection,
)
from websockets.client import (
from websockets import (
connect as ws_connect,
)
from websockets.typing import ( # type: ignore[import-not-found,unused-ignore]
Expand All @@ -35,7 +35,7 @@ async def ws_connect(*args, **kwargs):
raise NotImplementedError("Subscriptions require 'websockets' package.")
yield

WebSocketClientProtocol = Any # type: ignore[misc,assignment,unused-ignore]
ClientConnection = Any # type: ignore[misc,assignment,unused-ignore]
Data = Any # type: ignore[misc,assignment,unused-ignore]
Origin = Any # type: ignore[misc,assignment,unused-ignore]

Expand Down Expand Up @@ -304,7 +304,7 @@ async def _execute_json(
**merged_kwargs,
)

async def _send_connection_init(self, websocket: WebSocketClientProtocol) -> None:
async def _send_connection_init(self, websocket: ClientConnection) -> None:
payload: Dict[str, Any] = {
"type": GraphQLTransportWSMessageType.CONNECTION_INIT.value
}
Expand All @@ -314,7 +314,7 @@ async def _send_connection_init(self, websocket: WebSocketClientProtocol) -> Non

async def _send_subscribe(
self,
websocket: WebSocketClientProtocol,
websocket: ClientConnection,
operation_id: str,
query: str,
operation_name: Optional[str] = None,
Expand All @@ -334,7 +334,7 @@ async def _send_subscribe(
async def _handle_ws_message(
self,
message: Data,
websocket: WebSocketClientProtocol,
websocket: ClientConnection,
expected_type: Optional[GraphQLTransportWSMessageType] = None,
) -> Optional[Dict[str, Any]]:
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
)

try:
from websockets.client import ( # type: ignore[import-not-found,unused-ignore]
WebSocketClientProtocol,
from websockets import ( # type: ignore[import-not-found,unused-ignore]
ClientConnection,
)
from websockets.client import (
from websockets import (
connect as ws_connect,
)
from websockets.typing import ( # type: ignore[import-not-found,unused-ignore]
Expand All @@ -35,7 +35,7 @@ async def ws_connect(*args, **kwargs):
raise NotImplementedError("Subscriptions require 'websockets' package.")
yield

WebSocketClientProtocol = Any # type: ignore[misc,assignment,unused-ignore]
ClientConnection = Any # type: ignore[misc,assignment,unused-ignore]
Data = Any # type: ignore[misc,assignment,unused-ignore]
Origin = Any # type: ignore[misc,assignment,unused-ignore]

Expand Down Expand Up @@ -304,7 +304,7 @@ async def _execute_json(
**merged_kwargs,
)

async def _send_connection_init(self, websocket: WebSocketClientProtocol) -> None:
async def _send_connection_init(self, websocket: ClientConnection) -> None:
payload: Dict[str, Any] = {
"type": GraphQLTransportWSMessageType.CONNECTION_INIT.value
}
Expand All @@ -314,7 +314,7 @@ async def _send_connection_init(self, websocket: WebSocketClientProtocol) -> Non

async def _send_subscribe(
self,
websocket: WebSocketClientProtocol,
websocket: ClientConnection,
operation_id: str,
query: str,
operation_name: Optional[str] = None,
Expand All @@ -334,7 +334,7 @@ async def _send_subscribe(
async def _handle_ws_message(
self,
message: Data,
websocket: WebSocketClientProtocol,
websocket: ClientConnection,
expected_type: Optional[GraphQLTransportWSMessageType] = None,
) -> Optional[Dict[str, Any]]:
try:
Expand Down
Loading