From 30604b8db86373c76098e49655e17dae8ab5532b Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sat, 9 Sep 2023 04:58:20 -0500 Subject: [PATCH] clean up typing --- jupyter_server/_tz.py | 2 +- jupyter_server/nbconvert/handlers.py | 2 +- pyproject.toml | 2 +- tests/auth/test_identity.py | 2 +- tests/base/test_handlers.py | 2 +- tests/test_serverapp.py | 2 +- tests/unix_sockets/test_serverapp_integration.py | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/jupyter_server/_tz.py b/jupyter_server/_tz.py index 9769d878e2..4444c93db0 100644 --- a/jupyter_server/_tz.py +++ b/jupyter_server/_tz.py @@ -23,7 +23,7 @@ def dst(self, d): return ZERO -UTC = tzUTC() +UTC = tzUTC() # type:ignore[abstract] def utc_aware(unaware): diff --git a/jupyter_server/nbconvert/handlers.py b/jupyter_server/nbconvert/handlers.py index ae2e2d3d30..3d65b392d3 100644 --- a/jupyter_server/nbconvert/handlers.py +++ b/jupyter_server/nbconvert/handlers.py @@ -68,7 +68,7 @@ def get_exporter(format, **kwargs): """get an exporter, raising appropriate errors""" # if this fails, will raise 500 try: - from nbconvert.exporters.base import get_exporter # type:ignore[assignment] + from nbconvert.exporters.base import get_exporter except ImportError as e: raise web.HTTPError(500, "Could not import nbconvert: %s" % e) from e diff --git a/pyproject.toml b/pyproject.toml index 0a32aeb372..5ba07d5fb4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -104,7 +104,7 @@ nowarn = "test -W default {args}" [tool.hatch.envs.typing] features = ["test"] -dependencies = [ "mypy>=0.990" ] +dependencies = [ "mypy>=1.5.1" ] [tool.hatch.envs.typing.scripts] test = "mypy --install-types --non-interactive {args:.}" diff --git a/tests/auth/test_identity.py b/tests/auth/test_identity.py index 7e836d47f9..9c4010f445 100644 --- a/tests/auth/test_identity.py +++ b/tests/auth/test_identity.py @@ -174,7 +174,7 @@ def test_password_required(identity_provider_class, password_set, password_requi app.identity_provider = idp ctx = nullcontext() if ok else pytest.raises(SystemExit) - with ctx: # type:ignore[attr-defined] + with ctx: idp.validate_security(app, ssl_options=None) diff --git a/tests/base/test_handlers.py b/tests/base/test_handlers.py index f5a8763e79..98d6ff73dd 100644 --- a/tests/base/test_handlers.py +++ b/tests/base/test_handlers.py @@ -85,7 +85,7 @@ async def test_authenticated_file_handler(jp_serverapp, tmpdir): for key in list(handler.settings): if key != "contents_manager": del handler.settings[key] - handler.check_xsrf_cookie = MagicMock() # type:ignore[assignment] + handler.check_xsrf_cookie = MagicMock() # type:ignore[method-assign] handler._jupyter_current_user = "foo" # type:ignore[assignment] with warnings.catch_warnings(): warnings.simplefilter("ignore") diff --git a/tests/test_serverapp.py b/tests/test_serverapp.py index 326fe1a89a..9ea6e569f7 100644 --- a/tests/test_serverapp.py +++ b/tests/test_serverapp.py @@ -588,7 +588,7 @@ def test_browser_open_files(jp_configurable_serverapp, should_exist, caplog): assert os.path.exists(app.browser_open_file) == should_exist url = urljoin("file:", pathname2url(app.browser_open_file)) url_messages = [rec.message for rec in caplog.records if url in rec.message] - assert url_messages if should_exist else not url_messages # type: ignore[truthy-bool] + assert url_messages if should_exist else not url_messages def test_deprecated_notebook_dir_priority(jp_configurable_serverapp, tmp_path): diff --git a/tests/unix_sockets/test_serverapp_integration.py b/tests/unix_sockets/test_serverapp_integration.py index c5e769fae3..f60c99b1bc 100644 --- a/tests/unix_sockets/test_serverapp_integration.py +++ b/tests/unix_sockets/test_serverapp_integration.py @@ -78,8 +78,8 @@ def test_shutdown_sock_server_integration(jp_unix_socket_file): # Fake out stopping the server. app = JupyterServerStopApp(sock=str(jp_unix_socket_file)) app.initialize([]) - app.shutdown_server = lambda _: True # type:ignore[assignment] - app._maybe_remove_unix_socket = lambda _: _ # type: ignore[assignment] + app.shutdown_server = lambda _: True # type:ignore[method-assign] + app._maybe_remove_unix_socket = lambda _: _ # type: ignore[method-assign] app.start() _check_output(["jupyter-server", "stop", jp_unix_socket_file])