diff --git a/docs/source/rbac/generate-scope-table.py b/docs/source/rbac/generate-scope-table.py index 53057a4a..374871a7 100644 --- a/docs/source/rbac/generate-scope-table.py +++ b/docs/source/rbac/generate-scope-table.py @@ -13,6 +13,7 @@ The files are: This file is JupyterHub's REST API schema. Both a version and the RBAC scopes descriptions are updated in it. """ + import os from collections import defaultdict from pathlib import Path diff --git a/examples/bootstrap-script/jupyterhub_config.py b/examples/bootstrap-script/jupyterhub_config.py index 61eae47a..5fd02287 100644 --- a/examples/bootstrap-script/jupyterhub_config.py +++ b/examples/bootstrap-script/jupyterhub_config.py @@ -2,6 +2,7 @@ Example for a Spawner.pre_spawn_hook create a directory for the user before the spawner starts """ + # pylint: disable=import-error import os import shutil diff --git a/examples/external-oauth/whoami-oauth-basic.py b/examples/external-oauth/whoami-oauth-basic.py index a89f8db7..a234ec32 100644 --- a/examples/external-oauth/whoami-oauth-basic.py +++ b/examples/external-oauth/whoami-oauth-basic.py @@ -3,6 +3,7 @@ Implements OAuth handshake manually so all URLs and requests necessary for OAuth with JupyterHub should be in one place """ + import json import os from urllib.parse import urlencode, urlparse diff --git a/examples/service-whoami/whoami-oauth.py b/examples/service-whoami/whoami-oauth.py index 41466231..9422f857 100644 --- a/examples/service-whoami/whoami-oauth.py +++ b/examples/service-whoami/whoami-oauth.py @@ -4,6 +4,7 @@ This example service serves `/services/whoami-oauth/`, authenticated with the Hub, showing the user their own info. """ + import json import os from urllib.parse import urlparse diff --git a/examples/service-whoami/whoami.py b/examples/service-whoami/whoami.py index da79d9ad..f46fe47b 100644 --- a/examples/service-whoami/whoami.py +++ b/examples/service-whoami/whoami.py @@ -4,6 +4,7 @@ This serves `/services/whoami-api/`, authenticated with the Hub, showing the use HubAuthenticated only supports token-based access. """ + import json import os from urllib.parse import urlparse diff --git a/examples/spawn-form/jupyterhub_config.py b/examples/spawn-form/jupyterhub_config.py index 58fe59dc..5f58e9d8 100644 --- a/examples/spawn-form/jupyterhub_config.py +++ b/examples/spawn-form/jupyterhub_config.py @@ -1,6 +1,7 @@ """ Example JupyterHub config allowing users to specify environment variables and notebook-server args """ + import shlex from jupyterhub.spawner import LocalProcessSpawner diff --git a/jupyterhub/_memoize.py b/jupyterhub/_memoize.py index 7266340f..d13879c4 100644 --- a/jupyterhub/_memoize.py +++ b/jupyterhub/_memoize.py @@ -3,6 +3,7 @@ Note: a memoized function should always return an _immutable_ result to avoid later modifications polluting cached results. """ + from collections import OrderedDict from functools import wraps diff --git a/jupyterhub/_version.py b/jupyterhub/_version.py index 429a8a29..d7176912 100644 --- a/jupyterhub/_version.py +++ b/jupyterhub/_version.py @@ -1,4 +1,5 @@ """JupyterHub version info""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. # version_info updated by running `tbump` diff --git a/jupyterhub/alembic/versions/0eee8c825d24_added_properties_column.py b/jupyterhub/alembic/versions/0eee8c825d24_added_properties_column.py index 743ac32d..372bb6f6 100644 --- a/jupyterhub/alembic/versions/0eee8c825d24_added_properties_column.py +++ b/jupyterhub/alembic/versions/0eee8c825d24_added_properties_column.py @@ -5,6 +5,7 @@ Revises: 833da8570507 Create Date: 2021-09-15 14:04:09.067024 """ + # revision identifiers, used by Alembic. revision = '0eee8c825d24' down_revision = '651f5419b74d' diff --git a/jupyterhub/alembic/versions/19c0846f6344_base_revision_for_0_5.py b/jupyterhub/alembic/versions/19c0846f6344_base_revision_for_0_5.py index c8421da4..bfea3e30 100644 --- a/jupyterhub/alembic/versions/19c0846f6344_base_revision_for_0_5.py +++ b/jupyterhub/alembic/versions/19c0846f6344_base_revision_for_0_5.py @@ -5,6 +5,7 @@ Revises: Create Date: 2016-04-11 16:05:34.873288 """ + # revision identifiers, used by Alembic. revision = '19c0846f6344' down_revision = None diff --git a/jupyterhub/alembic/versions/1cebaf56856c_session_id.py b/jupyterhub/alembic/versions/1cebaf56856c_session_id.py index 38f37b0b..177c86d5 100644 --- a/jupyterhub/alembic/versions/1cebaf56856c_session_id.py +++ b/jupyterhub/alembic/versions/1cebaf56856c_session_id.py @@ -5,6 +5,7 @@ Revises: 3ec6993fe20c Create Date: 2017-12-07 14:43:51.500740 """ + # revision identifiers, used by Alembic. revision = '1cebaf56856c' down_revision = '3ec6993fe20c' diff --git a/jupyterhub/alembic/versions/3ec6993fe20c_encrypted_auth_state.py b/jupyterhub/alembic/versions/3ec6993fe20c_encrypted_auth_state.py index 73d8bc44..1d723d27 100644 --- a/jupyterhub/alembic/versions/3ec6993fe20c_encrypted_auth_state.py +++ b/jupyterhub/alembic/versions/3ec6993fe20c_encrypted_auth_state.py @@ -12,6 +12,7 @@ Revises: af4cbdb2d13c Create Date: 2017-07-28 16:44:40.413648 """ + # revision identifiers, used by Alembic. revision = '3ec6993fe20c' down_revision = 'af4cbdb2d13c' diff --git a/jupyterhub/alembic/versions/4dc2d5a8c53c_user_options.py b/jupyterhub/alembic/versions/4dc2d5a8c53c_user_options.py index 617a2d6d..43677642 100644 --- a/jupyterhub/alembic/versions/4dc2d5a8c53c_user_options.py +++ b/jupyterhub/alembic/versions/4dc2d5a8c53c_user_options.py @@ -5,6 +5,7 @@ Revises: 896818069c98 Create Date: 2019-02-28 14:14:27.423927 """ + # revision identifiers, used by Alembic. revision = '4dc2d5a8c53c' down_revision = '896818069c98' diff --git a/jupyterhub/alembic/versions/56cc5a70207e_token_tracking.py b/jupyterhub/alembic/versions/56cc5a70207e_token_tracking.py index 0c74c09d..3cd4e963 100644 --- a/jupyterhub/alembic/versions/56cc5a70207e_token_tracking.py +++ b/jupyterhub/alembic/versions/56cc5a70207e_token_tracking.py @@ -5,6 +5,7 @@ Revises: 1cebaf56856c Create Date: 2017-12-19 15:21:09.300513 """ + # revision identifiers, used by Alembic. revision = '56cc5a70207e' down_revision = '1cebaf56856c' diff --git a/jupyterhub/alembic/versions/651f5419b74d_api_token_scopes.py b/jupyterhub/alembic/versions/651f5419b74d_api_token_scopes.py index 76f9d910..b27fc8e1 100644 --- a/jupyterhub/alembic/versions/651f5419b74d_api_token_scopes.py +++ b/jupyterhub/alembic/versions/651f5419b74d_api_token_scopes.py @@ -5,6 +5,7 @@ Revises: 833da8570507 Create Date: 2022-02-28 12:42:55.149046 """ + # revision identifiers, used by Alembic. revision = '651f5419b74d' down_revision = '833da8570507' diff --git a/jupyterhub/alembic/versions/833da8570507_rbac.py b/jupyterhub/alembic/versions/833da8570507_rbac.py index ec3325ec..2fc7adba 100644 --- a/jupyterhub/alembic/versions/833da8570507_rbac.py +++ b/jupyterhub/alembic/versions/833da8570507_rbac.py @@ -6,6 +6,7 @@ Revises: 4dc2d5a8c53c Create Date: 2021-02-17 15:03:04.360368 """ + # revision identifiers, used by Alembic. revision = '833da8570507' down_revision = '4dc2d5a8c53c' diff --git a/jupyterhub/alembic/versions/896818069c98_token_expires.py b/jupyterhub/alembic/versions/896818069c98_token_expires.py index e8d1a84d..2611640b 100644 --- a/jupyterhub/alembic/versions/896818069c98_token_expires.py +++ b/jupyterhub/alembic/versions/896818069c98_token_expires.py @@ -5,6 +5,7 @@ Revises: d68c98b66cd4 Create Date: 2018-05-07 11:35:58.050542 """ + # revision identifiers, used by Alembic. revision = '896818069c98' down_revision = 'd68c98b66cd4' diff --git a/jupyterhub/alembic/versions/99a28a4418e1_user_created.py b/jupyterhub/alembic/versions/99a28a4418e1_user_created.py index fc2fca66..d0f0f80a 100644 --- a/jupyterhub/alembic/versions/99a28a4418e1_user_created.py +++ b/jupyterhub/alembic/versions/99a28a4418e1_user_created.py @@ -5,6 +5,7 @@ Revises: 56cc5a70207e Create Date: 2018-03-21 14:27:17.466841 """ + # revision identifiers, used by Alembic. revision = '99a28a4418e1' down_revision = '56cc5a70207e' diff --git a/jupyterhub/alembic/versions/af4cbdb2d13c_services.py b/jupyterhub/alembic/versions/af4cbdb2d13c_services.py index b33da18e..3c00b9cc 100644 --- a/jupyterhub/alembic/versions/af4cbdb2d13c_services.py +++ b/jupyterhub/alembic/versions/af4cbdb2d13c_services.py @@ -5,6 +5,7 @@ Revises: eeb276e51423 Create Date: 2016-07-28 16:16:38.245348 """ + # revision identifiers, used by Alembic. revision = 'af4cbdb2d13c' down_revision = 'eeb276e51423' diff --git a/jupyterhub/alembic/versions/d68c98b66cd4_client_description.py b/jupyterhub/alembic/versions/d68c98b66cd4_client_description.py index 4eb0a81e..51f3b5fb 100644 --- a/jupyterhub/alembic/versions/d68c98b66cd4_client_description.py +++ b/jupyterhub/alembic/versions/d68c98b66cd4_client_description.py @@ -5,6 +5,7 @@ Revises: 99a28a4418e1 Create Date: 2018-04-13 10:50:17.968636 """ + # revision identifiers, used by Alembic. revision = 'd68c98b66cd4' down_revision = '99a28a4418e1' diff --git a/jupyterhub/alembic/versions/eeb276e51423_auth_state.py b/jupyterhub/alembic/versions/eeb276e51423_auth_state.py index 5b4df64b..8358f422 100644 --- a/jupyterhub/alembic/versions/eeb276e51423_auth_state.py +++ b/jupyterhub/alembic/versions/eeb276e51423_auth_state.py @@ -6,6 +6,7 @@ Revision ID: eeb276e51423 Revises: 19c0846f6344 Create Date: 2016-04-11 16:06:49.239831 """ + # revision identifiers, used by Alembic. revision = 'eeb276e51423' down_revision = '19c0846f6344' diff --git a/jupyterhub/apihandlers/auth.py b/jupyterhub/apihandlers/auth.py index 84cde4f1..4b1f3898 100644 --- a/jupyterhub/apihandlers/auth.py +++ b/jupyterhub/apihandlers/auth.py @@ -1,4 +1,5 @@ """Authorization handlers""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import json diff --git a/jupyterhub/apihandlers/base.py b/jupyterhub/apihandlers/base.py index 94ed0307..aa01ba06 100644 --- a/jupyterhub/apihandlers/base.py +++ b/jupyterhub/apihandlers/base.py @@ -1,4 +1,5 @@ """Base API handlers""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import json diff --git a/jupyterhub/apihandlers/groups.py b/jupyterhub/apihandlers/groups.py index 3ae64a23..5b55b3c7 100644 --- a/jupyterhub/apihandlers/groups.py +++ b/jupyterhub/apihandlers/groups.py @@ -1,4 +1,5 @@ """Group handlers""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import json diff --git a/jupyterhub/apihandlers/hub.py b/jupyterhub/apihandlers/hub.py index a3090998..0a69f8f8 100644 --- a/jupyterhub/apihandlers/hub.py +++ b/jupyterhub/apihandlers/hub.py @@ -1,4 +1,5 @@ """API handlers for administering the Hub itself""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import json diff --git a/jupyterhub/apihandlers/proxy.py b/jupyterhub/apihandlers/proxy.py index c73326ab..b6fa6a53 100644 --- a/jupyterhub/apihandlers/proxy.py +++ b/jupyterhub/apihandlers/proxy.py @@ -1,4 +1,5 @@ """Proxy handlers""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import json diff --git a/jupyterhub/apihandlers/services.py b/jupyterhub/apihandlers/services.py index b9d23d84..e4420e93 100644 --- a/jupyterhub/apihandlers/services.py +++ b/jupyterhub/apihandlers/services.py @@ -2,6 +2,7 @@ Currently GET-only, no actions can be taken to modify services. """ + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import json diff --git a/jupyterhub/apihandlers/users.py b/jupyterhub/apihandlers/users.py index 22f81a22..a6953921 100644 --- a/jupyterhub/apihandlers/users.py +++ b/jupyterhub/apihandlers/users.py @@ -1,4 +1,5 @@ """User handlers""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import asyncio diff --git a/jupyterhub/auth.py b/jupyterhub/auth.py index 35dd9c6c..61de89d5 100644 --- a/jupyterhub/auth.py +++ b/jupyterhub/auth.py @@ -1,4 +1,5 @@ """Base Authenticator class and the default PAM Authenticator""" + # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. import inspect diff --git a/jupyterhub/dbutil.py b/jupyterhub/dbutil.py index 6466bdad..5f6608ec 100644 --- a/jupyterhub/dbutil.py +++ b/jupyterhub/dbutil.py @@ -1,4 +1,5 @@ """Database utilities for JupyterHub""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. # Based on pgcontents.utils.migrate, used under the Apache license. diff --git a/jupyterhub/handlers/base.py b/jupyterhub/handlers/base.py index c2785ea8..8f147d81 100644 --- a/jupyterhub/handlers/base.py +++ b/jupyterhub/handlers/base.py @@ -1,4 +1,5 @@ """HTTP Handlers for the hub server""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import asyncio diff --git a/jupyterhub/handlers/login.py b/jupyterhub/handlers/login.py index f4200933..3f6c6912 100644 --- a/jupyterhub/handlers/login.py +++ b/jupyterhub/handlers/login.py @@ -1,4 +1,5 @@ """HTTP Handlers for the hub server""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import asyncio diff --git a/jupyterhub/handlers/metrics.py b/jupyterhub/handlers/metrics.py index 674aeddd..587a1f19 100644 --- a/jupyterhub/handlers/metrics.py +++ b/jupyterhub/handlers/metrics.py @@ -1,4 +1,5 @@ """Handlers for serving prometheus metrics""" + from prometheus_client import CONTENT_TYPE_LATEST, REGISTRY, generate_latest from ..utils import metrics_authentication diff --git a/jupyterhub/handlers/pages.py b/jupyterhub/handlers/pages.py index 2ab13539..ac974496 100644 --- a/jupyterhub/handlers/pages.py +++ b/jupyterhub/handlers/pages.py @@ -1,4 +1,5 @@ """Basic html-rendering handlers.""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import asyncio diff --git a/jupyterhub/log.py b/jupyterhub/log.py index 4e5dd361..08d1a321 100644 --- a/jupyterhub/log.py +++ b/jupyterhub/log.py @@ -1,4 +1,5 @@ """logging utilities""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import json diff --git a/jupyterhub/oauth/provider.py b/jupyterhub/oauth/provider.py index 78668ab6..a60b3d9c 100644 --- a/jupyterhub/oauth/provider.py +++ b/jupyterhub/oauth/provider.py @@ -2,6 +2,7 @@ implements https://oauthlib.readthedocs.io/en/latest/oauth2/server.html """ + from oauthlib import uri_validate from oauthlib.oauth2 import RequestValidator, WebApplicationServer from oauthlib.oauth2.rfc6749.grant_types import authorization_code, base diff --git a/jupyterhub/objects.py b/jupyterhub/objects.py index f497e904..cb6632e4 100644 --- a/jupyterhub/objects.py +++ b/jupyterhub/objects.py @@ -1,4 +1,5 @@ """Some general objects for use in JupyterHub""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import socket diff --git a/jupyterhub/orm.py b/jupyterhub/orm.py index b45a5c17..554dccfe 100644 --- a/jupyterhub/orm.py +++ b/jupyterhub/orm.py @@ -1,4 +1,5 @@ """sqlalchemy ORM tools for the state of the constellation of processes""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import enum diff --git a/jupyterhub/proxy.py b/jupyterhub/proxy.py index 85fb23d7..8c21f8cc 100644 --- a/jupyterhub/proxy.py +++ b/jupyterhub/proxy.py @@ -14,6 +14,7 @@ Route Specification: 'host.tld/path/' for host-based routing or '/path/' for default routing. - Route paths should be normalized to always start and end with '/' """ + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import asyncio diff --git a/jupyterhub/roles.py b/jupyterhub/roles.py index 3ae2d008..f421016b 100644 --- a/jupyterhub/roles.py +++ b/jupyterhub/roles.py @@ -1,4 +1,5 @@ """Roles utils""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import re diff --git a/jupyterhub/scopes.py b/jupyterhub/scopes.py index 2381c4ee..16944618 100644 --- a/jupyterhub/scopes.py +++ b/jupyterhub/scopes.py @@ -14,6 +14,7 @@ intersection : set of expanded scopes as intersection of 2 expanded scope sets identify scopes: set of expanded scopes needed for identify (whoami) endpoints reduced scopes: expanded scopes that have been reduced """ + import functools import inspect import re diff --git a/jupyterhub/services/auth.py b/jupyterhub/services/auth.py index 574abda5..861af988 100644 --- a/jupyterhub/services/auth.py +++ b/jupyterhub/services/auth.py @@ -23,6 +23,7 @@ If you are using OAuth, you will also need to register an oauth callback handler A tornado implementation is provided in :class:`HubOAuthCallbackHandler`. """ + import asyncio import hashlib import json diff --git a/jupyterhub/services/service.py b/jupyterhub/services/service.py index e256d843..88d7f58a 100644 --- a/jupyterhub/services/service.py +++ b/jupyterhub/services/service.py @@ -38,6 +38,7 @@ A hub-managed service with no URL:: } """ + import asyncio import copy import os diff --git a/jupyterhub/singleuser/__init__.py b/jupyterhub/singleuser/__init__.py index 9b5d0f49..6addc3b3 100644 --- a/jupyterhub/singleuser/__init__.py +++ b/jupyterhub/singleuser/__init__.py @@ -12,6 +12,7 @@ Application subclass can be controlled with environment variables: - JUPYTERHUB_SINGLEUSER_EXTENSION=1 to opt-in to the extension (requires Jupyter Server 2) - JUPYTERHUB_SINGLEUSER_APP=notebook (or jupyter-server) to opt-in """ + import os from .mixins import HubAuthenticatedHandler, make_singleuser_app diff --git a/jupyterhub/singleuser/app.py b/jupyterhub/singleuser/app.py index f29d9978..15e2a0ac 100644 --- a/jupyterhub/singleuser/app.py +++ b/jupyterhub/singleuser/app.py @@ -8,6 +8,7 @@ Default app changed to launch `jupyter labhub`. Use JUPYTERHUB_SINGLEUSER_APP='notebook' for the legacy 'classic' notebook server (requires notebook<7). """ + import os from traitlets import import_item diff --git a/jupyterhub/singleuser/extension.py b/jupyterhub/singleuser/extension.py index 6929eb19..c2c684f1 100644 --- a/jupyterhub/singleuser/extension.py +++ b/jupyterhub/singleuser/extension.py @@ -613,9 +613,9 @@ class JupyterHubSingleUser(ExtensionApp): jinja_template_vars['logo_url'] = self.hub_auth.hub_host + url_path_join( self.hub_auth.hub_prefix, 'logo' ) - jinja_template_vars[ - 'hub_control_panel_url' - ] = self.hub_auth.hub_host + url_path_join(self.hub_auth.hub_prefix, 'home') + jinja_template_vars['hub_control_panel_url'] = ( + self.hub_auth.hub_host + url_path_join(self.hub_auth.hub_prefix, 'home') + ) _activity_task = None @@ -628,9 +628,9 @@ class JupyterHubSingleUser(ExtensionApp): super().initialize() app = self.serverapp - app.web_app.settings[ - "page_config_hook" - ] = app.identity_provider.page_config_hook + app.web_app.settings["page_config_hook"] = ( + app.identity_provider.page_config_hook + ) # if the user has configured a log function in the tornado settings, do not override it if not 'log_function' in app.config.ServerApp.get('tornado_settings', {}): app.web_app.settings["log_function"] = log_request diff --git a/jupyterhub/singleuser/mixins.py b/jupyterhub/singleuser/mixins.py index fa428d6a..5fb55c05 100755 --- a/jupyterhub/singleuser/mixins.py +++ b/jupyterhub/singleuser/mixins.py @@ -734,9 +734,9 @@ class SingleUserNotebookAppMixin(Configurable): ) self.jinja_template_vars['hub_host'] = self.hub_host self.jinja_template_vars['hub_prefix'] = self.hub_prefix - self.jinja_template_vars[ - 'hub_control_panel_url' - ] = self.hub_host + url_path_join(self.hub_prefix, 'home') + self.jinja_template_vars['hub_control_panel_url'] = ( + self.hub_host + url_path_join(self.hub_prefix, 'home') + ) settings = self.web_app.settings # patch classic notebook jinja env diff --git a/jupyterhub/spawner.py b/jupyterhub/spawner.py index 3d74572b..6c0306d2 100644 --- a/jupyterhub/spawner.py +++ b/jupyterhub/spawner.py @@ -1,6 +1,7 @@ """ Contains base Spawner class & default implementation """ + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import ast diff --git a/jupyterhub/tests/browser/test_browser.py b/jupyterhub/tests/browser/test_browser.py index dc38792a..9963e68e 100644 --- a/jupyterhub/tests/browser/test_browser.py +++ b/jupyterhub/tests/browser/test_browser.py @@ -878,9 +878,11 @@ async def test_oauth_page( user_scopes or ['(no_scope)'], user.name ) desc_list_expected = [ - f"{sd['description']} Applies to {sd['filter']}." - if sd.get('filter') - else sd['description'] + ( + f"{sd['description']} Applies to {sd['filter']}." + if sd.get('filter') + else sd['description'] + ) for sd in scope_descriptions ] assert sorted(desc_list_form) == sorted(desc_list_expected) diff --git a/jupyterhub/tests/conftest.py b/jupyterhub/tests/conftest.py index 5653fae1..c94dff54 100644 --- a/jupyterhub/tests/conftest.py +++ b/jupyterhub/tests/conftest.py @@ -23,6 +23,7 @@ Fixtures to add functionality or spawning behavior - `slow_bad_spawn` """ + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import asyncio diff --git a/jupyterhub/tests/mocking.py b/jupyterhub/tests/mocking.py index d19285d2..c4686829 100644 --- a/jupyterhub/tests/mocking.py +++ b/jupyterhub/tests/mocking.py @@ -26,6 +26,7 @@ Other components - public_url """ + import asyncio import os import sys diff --git a/jupyterhub/tests/mockserverapp.py b/jupyterhub/tests/mockserverapp.py index 84479e4b..0a90d33b 100644 --- a/jupyterhub/tests/mockserverapp.py +++ b/jupyterhub/tests/mockserverapp.py @@ -1,4 +1,5 @@ """Example JupyterServer app subclass""" + from jupyter_server.base.handlers import JupyterHandler from jupyter_server.serverapp import ServerApp from tornado import web diff --git a/jupyterhub/tests/mockservice.py b/jupyterhub/tests/mockservice.py index 2685cee4..69db5171 100644 --- a/jupyterhub/tests/mockservice.py +++ b/jupyterhub/tests/mockservice.py @@ -12,6 +12,7 @@ Handlers and their purpose include: - WhoAmIHandler: returns name of user making a request (deprecated cookie login) - OWhoAmIHandler: returns name of user making a request (OAuth login) """ + import json import os import pprint diff --git a/jupyterhub/tests/mocksu.py b/jupyterhub/tests/mocksu.py index e3683161..5416a9ff 100644 --- a/jupyterhub/tests/mocksu.py +++ b/jupyterhub/tests/mocksu.py @@ -11,6 +11,7 @@ Handlers and their purpose include: - ArgsHandler: allowing retrieval of `sys.argv`. """ + import json import os import sys diff --git a/jupyterhub/tests/populate_db.py b/jupyterhub/tests/populate_db.py index 4d4697ad..8a2add6e 100644 --- a/jupyterhub/tests/populate_db.py +++ b/jupyterhub/tests/populate_db.py @@ -4,6 +4,7 @@ Run with old versions of jupyterhub to test upgrade/downgrade used in test_db.py """ + from functools import partial import jupyterhub diff --git a/jupyterhub/tests/test_api.py b/jupyterhub/tests/test_api.py index 39e9c0b7..d8427821 100644 --- a/jupyterhub/tests/test_api.py +++ b/jupyterhub/tests/test_api.py @@ -1,4 +1,5 @@ """Tests for the REST API.""" + import asyncio import json import re diff --git a/jupyterhub/tests/test_app.py b/jupyterhub/tests/test_app.py index 4bc4316f..9a3f0e2a 100644 --- a/jupyterhub/tests/test_app.py +++ b/jupyterhub/tests/test_app.py @@ -1,4 +1,5 @@ """Test the JupyterHub entry point""" + import asyncio import binascii import json diff --git a/jupyterhub/tests/test_auth.py b/jupyterhub/tests/test_auth.py index 81a42c1f..f9a228ea 100644 --- a/jupyterhub/tests/test_auth.py +++ b/jupyterhub/tests/test_auth.py @@ -1,4 +1,5 @@ """Tests for PAM authentication""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import logging diff --git a/jupyterhub/tests/test_auth_expiry.py b/jupyterhub/tests/test_auth_expiry.py index 876f85b8..9e5e1b89 100644 --- a/jupyterhub/tests/test_auth_expiry.py +++ b/jupyterhub/tests/test_auth_expiry.py @@ -7,6 +7,7 @@ authentication can expire in a number of ways: - doesn't need refresh - needs refresh and cannot be refreshed without new login """ + from unittest import mock from urllib.parse import parse_qs, urlparse diff --git a/jupyterhub/tests/test_dummyauth.py b/jupyterhub/tests/test_dummyauth.py index dbeaf583..12886c7b 100644 --- a/jupyterhub/tests/test_dummyauth.py +++ b/jupyterhub/tests/test_dummyauth.py @@ -1,4 +1,5 @@ """Tests for dummy authentication""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. from jupyterhub.auth import DummyAuthenticator diff --git a/jupyterhub/tests/test_eventlog.py b/jupyterhub/tests/test_eventlog.py index 5b6649cd..0e83a840 100644 --- a/jupyterhub/tests/test_eventlog.py +++ b/jupyterhub/tests/test_eventlog.py @@ -5,6 +5,7 @@ To test a new schema or event, simply add it to the You *shouldn't* need to write new tests. """ + import io import json import logging diff --git a/jupyterhub/tests/test_internal_ssl_connections.py b/jupyterhub/tests/test_internal_ssl_connections.py index b2563578..33948f6c 100644 --- a/jupyterhub/tests/test_internal_ssl_connections.py +++ b/jupyterhub/tests/test_internal_ssl_connections.py @@ -1,4 +1,5 @@ """Tests for jupyterhub internal_ssl connections""" + import sys import time from unittest import mock diff --git a/jupyterhub/tests/test_named_servers.py b/jupyterhub/tests/test_named_servers.py index 2b0cdf33..4d5219c4 100644 --- a/jupyterhub/tests/test_named_servers.py +++ b/jupyterhub/tests/test_named_servers.py @@ -1,4 +1,5 @@ """Tests for named servers""" + import asyncio import json import time diff --git a/jupyterhub/tests/test_objects.py b/jupyterhub/tests/test_objects.py index f24de313..d1df230f 100644 --- a/jupyterhub/tests/test_objects.py +++ b/jupyterhub/tests/test_objects.py @@ -1,4 +1,5 @@ """Tests for basic object-wrappers""" + import socket import pytest diff --git a/jupyterhub/tests/test_orm.py b/jupyterhub/tests/test_orm.py index b953d3f9..577f07e5 100644 --- a/jupyterhub/tests/test_orm.py +++ b/jupyterhub/tests/test_orm.py @@ -1,4 +1,5 @@ """Tests for the ORM bits""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import os diff --git a/jupyterhub/tests/test_pages.py b/jupyterhub/tests/test_pages.py index f8f6ded7..742084e1 100644 --- a/jupyterhub/tests/test_pages.py +++ b/jupyterhub/tests/test_pages.py @@ -1,4 +1,5 @@ """Tests for HTML pages""" + import asyncio import sys from unittest import mock diff --git a/jupyterhub/tests/test_proxy.py b/jupyterhub/tests/test_proxy.py index 97e955f0..86f941e4 100644 --- a/jupyterhub/tests/test_proxy.py +++ b/jupyterhub/tests/test_proxy.py @@ -1,4 +1,5 @@ """Test a proxy being started before the Hub""" + import json import os from contextlib import contextmanager diff --git a/jupyterhub/tests/test_roles.py b/jupyterhub/tests/test_roles.py index bd61c061..28e4b20f 100644 --- a/jupyterhub/tests/test_roles.py +++ b/jupyterhub/tests/test_roles.py @@ -1,4 +1,5 @@ """Test roles""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import json diff --git a/jupyterhub/tests/test_scopes.py b/jupyterhub/tests/test_scopes.py index 62ccbae7..c1a29c35 100644 --- a/jupyterhub/tests/test_scopes.py +++ b/jupyterhub/tests/test_scopes.py @@ -1,4 +1,5 @@ """Test scopes for API handlers""" + from operator import itemgetter from unittest import mock diff --git a/jupyterhub/tests/test_services.py b/jupyterhub/tests/test_services.py index b1e9fe9f..389b7930 100644 --- a/jupyterhub/tests/test_services.py +++ b/jupyterhub/tests/test_services.py @@ -1,4 +1,5 @@ """Tests for services""" + import os import sys from binascii import hexlify diff --git a/jupyterhub/tests/test_services_auth.py b/jupyterhub/tests/test_services_auth.py index 615abf8c..42c4fa72 100644 --- a/jupyterhub/tests/test_services_auth.py +++ b/jupyterhub/tests/test_services_auth.py @@ -1,4 +1,5 @@ """Tests for service authentication""" + import copy import os import sys diff --git a/jupyterhub/tests/test_singleuser.py b/jupyterhub/tests/test_singleuser.py index 2b9695d4..769a7755 100644 --- a/jupyterhub/tests/test_singleuser.py +++ b/jupyterhub/tests/test_singleuser.py @@ -1,4 +1,5 @@ """Tests for jupyterhub.singleuser""" + import os import sys from contextlib import nullcontext diff --git a/jupyterhub/tests/test_spawner.py b/jupyterhub/tests/test_spawner.py index c4da2f06..aa66e99b 100644 --- a/jupyterhub/tests/test_spawner.py +++ b/jupyterhub/tests/test_spawner.py @@ -1,4 +1,5 @@ """Tests for process spawning""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import asyncio diff --git a/jupyterhub/tests/test_utils.py b/jupyterhub/tests/test_utils.py index cfc6c049..8b96fb36 100644 --- a/jupyterhub/tests/test_utils.py +++ b/jupyterhub/tests/test_utils.py @@ -1,4 +1,5 @@ """Tests for utilities""" + import asyncio import time from concurrent.futures import ThreadPoolExecutor diff --git a/jupyterhub/tests/test_version.py b/jupyterhub/tests/test_version.py index 2f251f8c..832797f0 100644 --- a/jupyterhub/tests/test_version.py +++ b/jupyterhub/tests/test_version.py @@ -1,4 +1,5 @@ """Test version checking""" + import logging import pytest diff --git a/jupyterhub/traitlets.py b/jupyterhub/traitlets.py index a7ed5829..e326418f 100644 --- a/jupyterhub/traitlets.py +++ b/jupyterhub/traitlets.py @@ -1,6 +1,7 @@ """ Traitlets that are used in JupyterHub """ + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import sys diff --git a/jupyterhub/user.py b/jupyterhub/user.py index ac2094f9..2753012a 100644 --- a/jupyterhub/user.py +++ b/jupyterhub/user.py @@ -795,9 +795,9 @@ class User: await spawner.run_auth_state_hook(auth_state) # update spawner start time, and activity for both spawner and user - self.last_activity = ( - spawner.orm_spawner.started - ) = spawner.orm_spawner.last_activity = utcnow(with_tz=False) + self.last_activity = spawner.orm_spawner.started = ( + spawner.orm_spawner.last_activity + ) = utcnow(with_tz=False) db.commit() # wait for spawner.start to return # run optional preparation work to bootstrap the notebook diff --git a/jupyterhub/utils.py b/jupyterhub/utils.py index 426fd30c..04a91464 100644 --- a/jupyterhub/utils.py +++ b/jupyterhub/utils.py @@ -1,4 +1,5 @@ """Miscellaneous utilities""" + # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import asyncio