Skip to content

Commit

Permalink
update type handling
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Oct 11, 2022
1 parent 9ff2029 commit c3a5e4f
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions jupyter_server_terminals/api_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .base import TerminalsMixin

try:
from jupyter_server.auth import authorized
from jupyter_server.auth.decorator import authorized
from jupyter_server.base.handlers import APIHandler
except ModuleNotFoundError:
raise ModuleNotFoundError("Jupyter Server must be installed to use this extension.")
Expand Down Expand Up @@ -60,7 +60,7 @@ def post(self):


class TerminalHandler(TerminalsMixin, TerminalAPIHandler):
SUPPORTED_METHODS = ("GET", "DELETE")
SUPPORTED_METHODS = ("GET", "DELETE") # type:ignore[assignment]

@web.authenticated
@authorized
Expand Down
2 changes: 1 addition & 1 deletion jupyter_server_terminals/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
class TerminalsMixin(ExtensionHandlerMixin):
@property
def terminal_manager(self):
return self.settings["terminal_manager"]
return self.settings["terminal_manager"] # type:ignore[attr-defined]
5 changes: 3 additions & 2 deletions jupyter_server_terminals/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import terminado
from terminado.websocket import TermSocket as BaseTermSocket
from tornado import web

from .base import TerminalsMixin
Expand All @@ -17,12 +18,12 @@
AUTH_RESOURCE = "terminals"


class TermSocket(TerminalsMixin, WebSocketMixin, JupyterHandler, terminado.TermSocket):
class TermSocket(TerminalsMixin, WebSocketMixin, JupyterHandler, BaseTermSocket):

auth_resource = AUTH_RESOURCE

def initialize(self, name, term_manager, **kwargs):
terminado.TermSocket.initialize(self, term_manager, **kwargs)
BaseTermSocket.initialize(self, term_manager, **kwargs)
TerminalsMixin.initialize(self, name)

def origin_check(self):
Expand Down
8 changes: 5 additions & 3 deletions jupyter_server_terminals/terminalmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@
# Distributed under the terms of the Modified BSD License.
from datetime import timedelta

import terminado
from terminado.management import NamedTermManager
from tornado import web
from tornado.ioloop import IOLoop, PeriodicCallback
from traitlets import Integer
from traitlets.config import LoggingConfigurable

try:
from jupyter_server._tz import isoformat, utcnow
from jupyter_server.prometheus.metrics import TERMINAL_CURRENTLY_RUNNING_TOTAL
from jupyter_server.prometheus.metrics import ( # type:ignore[attr-defined]
TERMINAL_CURRENTLY_RUNNING_TOTAL,
)
except ModuleNotFoundError:
raise ModuleNotFoundError("Jupyter Server must be installed to use this extension.")


class TerminalManager(LoggingConfigurable, terminado.NamedTermManager):
class TerminalManager(LoggingConfigurable, NamedTermManager): # type:ignore[misc]
""" """

_culler_callback = None
Expand Down
2 changes: 1 addition & 1 deletion tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from jupyter_server.auth.utils import HTTP_METHOD_TO_AUTH_ACTION, match_url_to_resource
from tornado.httpclient import HTTPClientError
from tornado.websocket import WebSocketHandler
from traitlets.config import Config
from traitlets.config.loader import Config


class AuthorizerforTesting(Authorizer):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest
from tornado.httpclient import HTTPClientError
from traitlets.config import Config
from traitlets.config.loader import Config


@pytest.fixture
Expand Down

0 comments on commit c3a5e4f

Please sign in to comment.