Skip to content

Commit bf15cef

Browse files
committed
Address linting issues
1 parent 188b5ca commit bf15cef

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

jupyter_server/gateway/gateway_client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from jupyter_events import EventLogger
1919
from tornado import web
2020
from tornado.httpclient import AsyncHTTPClient, HTTPClientError, HTTPResponse
21-
from tornado.httputil import HTTPHeaders
2221
from traitlets import (
2322
Bool,
2423
Float,
@@ -42,7 +41,7 @@
4241
MESSAGE_KEY = "msg"
4342

4443
if ty.TYPE_CHECKING:
45-
from http.cookies import Morsel
44+
from tornado.httputil import HTTPHeaders
4645

4746

4847
class GatewayTokenRenewerMeta(ABCMeta, type(LoggingConfigurable)): # type: ignore[misc]
@@ -640,7 +639,7 @@ def update_cookies(self, headers: HTTPHeaders) -> None:
640639
# Get individual Set-Cookie headers in list form. This handles multiple cookies
641640
# that are otherwise comma-separated in the header and will break the parsing logic
642641
# if only headers.get() is used.
643-
cookie_headers = headers.get_list('Set-Cookie')
642+
cookie_headers = headers.get_list("Set-Cookie")
644643
if not cookie_headers:
645644
return
646645

tests/test_gateway.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from jupyter_core.utils import ensure_async
1717
from tornado.concurrent import Future
1818
from tornado.httpclient import HTTPRequest, HTTPResponse
19-
from tornado.httputil import HTTPServerRequest, HTTPHeaders
19+
from tornado.httputil import HTTPHeaders, HTTPServerRequest
2020
from tornado.queues import Queue
2121
from tornado.web import HTTPError
2222
from traitlets import Int, Unicode
@@ -372,6 +372,7 @@ def test_gateway_request_timeout_pad_option(
372372

373373
GatewayClient.clear_instance()
374374

375+
375376
@pytest.mark.parametrize(
376377
"accept_cookies,expire_arg,expire_param,existing_cookies",
377378
[
@@ -399,8 +400,9 @@ def test_gateway_request_with_expiring_cookies(
399400
cookie_value = "SERVERID=1234567; Path=/; HttpOnly"
400401
if expire_arg == "expires":
401402
# Convert expire_param to a string in the format of "Expires: <date>" (RFC 7231)
402-
expire_param = (datetime.now(tz=timezone.utc) + timedelta(seconds=expire_param))\
403-
.strftime("%a, %d %b %Y %H:%M:%S GMT")
403+
expire_param = (datetime.now(tz=timezone.utc) + timedelta(seconds=expire_param)).strftime(
404+
"%a, %d %b %Y %H:%M:%S GMT"
405+
)
404406
cookie_value = f"SERVERID=1234567; Path=/; expires={expire_param}; HttpOnly"
405407
elif expire_arg == "Max-Age":
406408
cookie_value = f"SERVERID=1234567; Path=/; Max-Age={expire_param}; HttpOnly"
@@ -421,7 +423,7 @@ def test_gateway_request_with_expiring_cookies(
421423
connection_args = GatewayClient.instance().load_connection_args(**args)
422424

423425
if not accept_cookies or test_expiration:
424-
# The first condition ensure the response cookie is not accepted,
426+
# The first condition ensure the response cookie is not accepted,
425427
# the second condition ensures that the cookie is not accepted if it is expired.
426428
assert "SERVERID" not in connection_args["headers"].get("Cookie")
427429
else:

0 commit comments

Comments
 (0)