diff --git a/docs/source/conf.py b/docs/source/conf.py index fd0d4b92..bf6d7ed1 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # import os -import shlex import sys # Set paths diff --git a/examples/external-oauth/whoami-oauth-basic.py b/examples/external-oauth/whoami-oauth-basic.py index ad98115c..2aca9f55 100644 --- a/examples/external-oauth/whoami-oauth-basic.py +++ b/examples/external-oauth/whoami-oauth-basic.py @@ -5,13 +5,11 @@ so all URLs and requests necessary for OAuth with JupyterHub should be in one pl """ import json import os -import sys from urllib.parse import urlencode from urllib.parse import urlparse from tornado import log from tornado import web -from tornado.auth import OAuth2Mixin from tornado.httpclient import AsyncHTTPClient from tornado.httpclient import HTTPRequest from tornado.httputil import url_concat diff --git a/examples/service-announcement/announcement.py b/examples/service-announcement/announcement.py index 2b140fdb..a0cf5964 100644 --- a/examples/service-announcement/announcement.py +++ b/examples/service-announcement/announcement.py @@ -4,7 +4,6 @@ import json import os from tornado import escape -from tornado import gen from tornado import ioloop from tornado import web diff --git a/examples/service-whoami-flask/jupyterhub_config.py b/examples/service-whoami-flask/jupyterhub_config.py index 54d3c736..63ddaa38 100644 --- a/examples/service-whoami-flask/jupyterhub_config.py +++ b/examples/service-whoami-flask/jupyterhub_config.py @@ -1,6 +1,3 @@ -import os -import sys - c.JupyterHub.services = [ { 'name': 'whoami', diff --git a/examples/service-whoami/jupyterhub_config.py b/examples/service-whoami/jupyterhub_config.py index d9ccd889..1d1f9435 100644 --- a/examples/service-whoami/jupyterhub_config.py +++ b/examples/service-whoami/jupyterhub_config.py @@ -1,4 +1,3 @@ -import os import sys c.JupyterHub.services = [ diff --git a/examples/service-whoami/whoami-oauth.py b/examples/service-whoami/whoami-oauth.py index c1a576c9..72c97dda 100644 --- a/examples/service-whoami/whoami-oauth.py +++ b/examples/service-whoami/whoami-oauth.py @@ -6,7 +6,6 @@ showing the user their own info. """ import json import os -from getpass import getuser from urllib.parse import urlparse from tornado.httpserver import HTTPServer @@ -25,6 +24,7 @@ class WhoAmIHandler(HubOAuthenticated, RequestHandler): # `getuser()` here would mean only the user who started the service # can access the service: + # from getpass import getuser # hub_users = {getuser()} @authenticated diff --git a/examples/service-whoami/whoami.py b/examples/service-whoami/whoami.py index 6dc56c9e..2a5a3373 100644 --- a/examples/service-whoami/whoami.py +++ b/examples/service-whoami/whoami.py @@ -4,7 +4,6 @@ This serves `/services/whoami/`, authenticated with the Hub, showing the user th """ import json import os -from getpass import getuser from urllib.parse import urlparse from tornado.httpserver import HTTPServer @@ -21,6 +20,7 @@ class WhoAmIHandler(HubAuthenticated, RequestHandler): # `getuser()` here would mean only the user who started the service # can access the service: + # from getpass import getuser # hub_users = {getuser()} @authenticated diff --git a/jupyterhub/apihandlers/groups.py b/jupyterhub/apihandlers/groups.py index 78e833f7..e6b439ba 100644 --- a/jupyterhub/apihandlers/groups.py +++ b/jupyterhub/apihandlers/groups.py @@ -3,7 +3,6 @@ # Distributed under the terms of the Modified BSD License. import json -from tornado import gen from tornado import web from .. import orm diff --git a/jupyterhub/apihandlers/proxy.py b/jupyterhub/apihandlers/proxy.py index 83901832..0a43583b 100644 --- a/jupyterhub/apihandlers/proxy.py +++ b/jupyterhub/apihandlers/proxy.py @@ -2,12 +2,9 @@ # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import json -from urllib.parse import urlparse -from tornado import gen from tornado import web -from .. import orm from ..utils import admin_only from .base import APIHandler diff --git a/jupyterhub/crypto.py b/jupyterhub/crypto.py index 57bd00d3..039201b1 100644 --- a/jupyterhub/crypto.py +++ b/jupyterhub/crypto.py @@ -6,7 +6,6 @@ from concurrent.futures import ThreadPoolExecutor from traitlets import Any from traitlets import default -from traitlets import Dict from traitlets import Integer from traitlets import List from traitlets import observe diff --git a/jupyterhub/handlers/base.py b/jupyterhub/handlers/base.py index 9606fa61..f8ecf348 100644 --- a/jupyterhub/handlers/base.py +++ b/jupyterhub/handlers/base.py @@ -2,7 +2,6 @@ # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import asyncio -import copy import json import math import random @@ -27,14 +26,12 @@ from tornado.httputil import url_concat from tornado.ioloop import IOLoop from tornado.log import app_log from tornado.web import addslash -from tornado.web import MissingArgumentError from tornado.web import RequestHandler from .. import __version__ from .. import orm from ..metrics import PROXY_ADD_DURATION_SECONDS from ..metrics import PROXY_DELETE_DURATION_SECONDS -from ..metrics import ProxyAddStatus from ..metrics import ProxyDeleteStatus from ..metrics import RUNNING_SERVERS from ..metrics import SERVER_POLL_DURATION_SECONDS diff --git a/jupyterhub/handlers/metrics.py b/jupyterhub/handlers/metrics.py index f7a95b62..0f63d9c3 100644 --- a/jupyterhub/handlers/metrics.py +++ b/jupyterhub/handlers/metrics.py @@ -1,7 +1,6 @@ from prometheus_client import CONTENT_TYPE_LATEST from prometheus_client import generate_latest from prometheus_client import REGISTRY -from tornado import gen from ..utils import metrics_authentication from .base import BaseHandler diff --git a/jupyterhub/handlers/pages.py b/jupyterhub/handlers/pages.py index 5cd1f4a7..ec378b9a 100644 --- a/jupyterhub/handlers/pages.py +++ b/jupyterhub/handlers/pages.py @@ -2,15 +2,12 @@ # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import asyncio -import codecs -import copy import time from collections import defaultdict from datetime import datetime from http.client import responses from jinja2 import TemplateNotFound -from tornado import gen from tornado import web from tornado.httputil import url_concat @@ -464,7 +461,6 @@ class AdminHandler(BaseHandler): users = self.db.query(orm.User).outerjoin(orm.Spawner).order_by(*ordered) users = [self._user_from_orm(u) for u in users] - from itertools import chain running = [] for u in users: diff --git a/jupyterhub/oauth/provider.py b/jupyterhub/oauth/provider.py index 6157223f..fd529cc9 100644 --- a/jupyterhub/oauth/provider.py +++ b/jupyterhub/oauth/provider.py @@ -3,15 +3,12 @@ implements https://oauthlib.readthedocs.io/en/latest/oauth2/server.html """ from datetime import datetime -from urllib.parse import urlparse from oauthlib import uri_validate from oauthlib.oauth2 import RequestValidator from oauthlib.oauth2 import WebApplicationServer from oauthlib.oauth2.rfc6749.grant_types import authorization_code from oauthlib.oauth2.rfc6749.grant_types import base -from sqlalchemy.orm import scoped_session -from tornado import web from tornado.escape import url_escape from tornado.log import app_log diff --git a/jupyterhub/proxy.py b/jupyterhub/proxy.py index cbe1cba3..0666bcda 100644 --- a/jupyterhub/proxy.py +++ b/jupyterhub/proxy.py @@ -24,7 +24,6 @@ import time from functools import wraps from subprocess import Popen from urllib.parse import quote -from urllib.parse import urlparse from tornado import gen from tornado.httpclient import AsyncHTTPClient diff --git a/jupyterhub/spawner.py b/jupyterhub/spawner.py index 4abc355b..56761516 100644 --- a/jupyterhub/spawner.py +++ b/jupyterhub/spawner.py @@ -4,8 +4,6 @@ Contains base Spawner class & default implementation # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import ast -import asyncio -import errno import json import os import pipes diff --git a/jupyterhub/tests/test_api.py b/jupyterhub/tests/test_api.py index aedb4426..47751621 100644 --- a/jupyterhub/tests/test_api.py +++ b/jupyterhub/tests/test_api.py @@ -1,5 +1,4 @@ """Tests for the REST API.""" -import asyncio import json import re import sys diff --git a/jupyterhub/tests/test_app.py b/jupyterhub/tests/test_app.py index bc59176b..bce50ae6 100644 --- a/jupyterhub/tests/test_app.py +++ b/jupyterhub/tests/test_app.py @@ -7,13 +7,11 @@ import time from subprocess import check_output from subprocess import PIPE from subprocess import Popen -from subprocess import run from tempfile import NamedTemporaryFile from tempfile import TemporaryDirectory from unittest.mock import patch import pytest -from tornado import gen from traitlets.config import Config from .. import orm diff --git a/jupyterhub/tests/test_auth.py b/jupyterhub/tests/test_auth.py index 10ae0b1a..a2fb98c5 100644 --- a/jupyterhub/tests/test_auth.py +++ b/jupyterhub/tests/test_auth.py @@ -1,7 +1,6 @@ """Tests for PAM authentication""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. -import os from unittest import mock import pytest diff --git a/jupyterhub/tests/test_auth_expiry.py b/jupyterhub/tests/test_auth_expiry.py index 781c751b..48f85eb4 100644 --- a/jupyterhub/tests/test_auth_expiry.py +++ b/jupyterhub/tests/test_auth_expiry.py @@ -7,7 +7,6 @@ authentication can expire in a number of ways: - doesn't need refresh - needs refresh and cannot be refreshed without new login """ -import asyncio from contextlib import contextmanager from unittest import mock from urllib.parse import parse_qs diff --git a/jupyterhub/tests/test_dummyauth.py b/jupyterhub/tests/test_dummyauth.py index 3f34c343..dbeaf583 100644 --- a/jupyterhub/tests/test_dummyauth.py +++ b/jupyterhub/tests/test_dummyauth.py @@ -1,8 +1,6 @@ """Tests for dummy authentication""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. -import pytest - from jupyterhub.auth import DummyAuthenticator diff --git a/jupyterhub/tests/test_internal_ssl_app.py b/jupyterhub/tests/test_internal_ssl_app.py index 95b382c4..cae0519b 100644 --- a/jupyterhub/tests/test_internal_ssl_app.py +++ b/jupyterhub/tests/test_internal_ssl_app.py @@ -1,8 +1,6 @@ """Test the JupyterHub entry point with internal ssl""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. -import sys - import jupyterhub.tests.mocking from jupyterhub.tests.test_app import * diff --git a/jupyterhub/tests/test_proxy.py b/jupyterhub/tests/test_proxy.py index 0de5748b..e912bc62 100644 --- a/jupyterhub/tests/test_proxy.py +++ b/jupyterhub/tests/test_proxy.py @@ -2,7 +2,6 @@ import json import os from contextlib import contextmanager -from queue import Queue from subprocess import Popen from urllib.parse import quote from urllib.parse import urlparse diff --git a/jupyterhub/tests/test_services.py b/jupyterhub/tests/test_services.py index 248de1b1..127a9f45 100644 --- a/jupyterhub/tests/test_services.py +++ b/jupyterhub/tests/test_services.py @@ -2,18 +2,13 @@ import asyncio import os import sys -import time from binascii import hexlify from contextlib import contextmanager from subprocess import Popen -from threading import Event -import pytest -import requests from async_generator import async_generator from async_generator import asynccontextmanager from async_generator import yield_ -from tornado import gen from tornado.ioloop import IOLoop from ..utils import maybe_future diff --git a/jupyterhub/tests/test_services_auth.py b/jupyterhub/tests/test_services_auth.py index de4d73e9..a57ba871 100644 --- a/jupyterhub/tests/test_services_auth.py +++ b/jupyterhub/tests/test_services_auth.py @@ -11,7 +11,6 @@ from threading import Thread from unittest import mock from urllib.parse import urlparse -import pytest import requests import requests_mock from pytest import raises diff --git a/jupyterhub/tests/test_singleuser.py b/jupyterhub/tests/test_singleuser.py index 1bd08696..0e4d3bd7 100644 --- a/jupyterhub/tests/test_singleuser.py +++ b/jupyterhub/tests/test_singleuser.py @@ -3,8 +3,6 @@ import sys from subprocess import check_output from urllib.parse import urlparse -import pytest - import jupyterhub from ..utils import url_path_join from .mocking import public_url diff --git a/jupyterhub/utils.py b/jupyterhub/utils.py index 851b4d53..524fd093 100644 --- a/jupyterhub/utils.py +++ b/jupyterhub/utils.py @@ -444,7 +444,6 @@ def print_stacks(file=sys.stderr): # local imports because these will not be used often, # no need to add them to startup import asyncio - import resource import traceback from .log import coroutine_frames diff --git a/setup.py b/setup.py index 5a5f4176..dbd1f3d3 100755 --- a/setup.py +++ b/setup.py @@ -10,7 +10,6 @@ from __future__ import print_function import os import shutil import sys -from glob import glob from subprocess import check_call from setuptools import setup