Skip to content

Commit

Permalink
refactor: ignore type at assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
brussee committed Jan 10, 2023
1 parent aacd0bd commit e1666f5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
4 changes: 1 addition & 3 deletions uvicorn/protocols/http/h11_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,8 @@ def handle_events(self) -> None:
"raw_path": raw_path,
"query_string": query_string,
"headers": self.headers,
"extensions": {},
"extensions": ({"tls": self.tls} if self.scheme == "https" else {}),
}
if self.scheme == "https":
self.scope["extensions"]["tls"] = self.tls

upgrade = self._get_upgrade()
if upgrade == b"websocket" and self._should_upgrade_to_ws():
Expand Down
4 changes: 1 addition & 3 deletions uvicorn/protocols/http/httptools_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,8 @@ def on_message_begin(self) -> None:
"scheme": self.scheme,
"root_path": self.root_path,
"headers": self.headers,
"extensions": {},
"extensions": ({"tls": self.tls} if self.scheme == "https" else {}),
}
if self.scheme == "https":
self.scope["extensions"]["tls"] = self.tls

# Parser callbacks
def on_url(self, url: bytes) -> None:
Expand Down
4 changes: 1 addition & 3 deletions uvicorn/protocols/websockets/websockets_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,8 @@ async def process_request(
"query_string": query_string.encode("ascii"),
"headers": asgi_headers,
"subprotocols": subprotocols,
"extensions": {},
"extensions": ({"tls": self.tls} if self.scheme == "wss" else {}),
}
if self.scheme == "wss":
self.scope["extensions"]["tls"] = self.tls
task = self.loop.create_task(self.run_asgi())
task.add_done_callback(self.on_task_complete)
self.tasks.add(task)
Expand Down
6 changes: 2 additions & 4 deletions uvicorn/protocols/websockets/wsproto_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def handle_connect(self, event: events.Request) -> None:
headers = [(b"host", event.host.encode())]
headers += [(key.lower(), value) for key, value in event.extra_headers]
raw_path, _, query_string = event.target.partition("?")
self.scope: "WebSocketScope" = {
self.scope: "WebSocketScope" = { # type: ignore[typeddict-item]
"type": "websocket",
"asgi": {"version": self.config.asgi_version, "spec_version": "2.3"},
"http_version": "1.1",
Expand All @@ -191,10 +191,8 @@ def handle_connect(self, event: events.Request) -> None:
"query_string": query_string.encode("ascii"),
"headers": headers,
"subprotocols": event.subprotocols,
"extensions": {},
"extensions": ({"tls": self.tls} if self.scheme == "wss" else {}),
}
if self.scheme == "wss":
self.scope["extensions"]["tls"] = self.tls
self.queue.put_nowait({"type": "websocket.connect"})
task = self.loop.create_task(self.run_asgi())
task.add_done_callback(self.on_task_complete)
Expand Down

0 comments on commit e1666f5

Please sign in to comment.