Skip to content

Commit

Permalink
pre-commit: run reorder-python-imports
Browse files Browse the repository at this point in the history
  • Loading branch information
consideRatio committed May 14, 2021
1 parent 4de7510 commit 95e4464
Show file tree
Hide file tree
Showing 34 changed files with 147 additions and 113 deletions.
2 changes: 0 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# http://www.sphinx-doc.org/en/master/config

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand Down
10 changes: 6 additions & 4 deletions docs/source/example-oauthenticator.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
"""
Example OAuthenticator to use with My Service
"""


import json

from jupyterhub.auth import LocalAuthenticator
from oauthenticator.oauth2 import OAuthLoginHandler, OAuthenticator
from tornado.auth import OAuth2Mixin
from tornado.httpclient import AsyncHTTPClient
from tornado.httpclient import HTTPError
from tornado.httpclient import HTTPRequest
from tornado.httputil import url_concat
from tornado.httpclient import HTTPRequest, AsyncHTTPClient, HTTPError

from oauthenticator.oauth2 import OAuthenticator
from oauthenticator.oauth2 import OAuthLoginHandler


class MyServiceMixin(OAuth2Mixin):
Expand Down
4 changes: 2 additions & 2 deletions examples/auth_state/jupyterhub_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
2. pass select auth_state to Spawner via environment variables
3. enable auth_state via `JUPYTERHUB_CRYPT_KEY` and `enable_auth_state = True`
"""

import os
import warnings

from oauthenticator.github import GitHubOAuthenticator
from tornado import gen

from oauthenticator.github import GitHubOAuthenticator

# define our OAuthenticator with `.pre_spawn_start`
# for passing auth_state into the user environment

Expand Down
1 change: 1 addition & 0 deletions examples/azuread/sample_jupyter_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os

from oauthenticator.azuread import AzureAdOAuthenticator

c.JupyterHub.authenticator_class = AzureAdOAuthenticator
Expand Down
10 changes: 5 additions & 5 deletions oauthenticator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# include github, bitbucket, google here for backward-compatibility
# don't add new oauthenticators here.
from .oauth2 import *
from .github import *
from ._version import __version__
from ._version import version_info
from .bitbucket import *
from .google import *
from .cilogon import *

from ._version import __version__, version_info
from .github import *
from .google import *
from .oauth2 import *
1 change: 0 additions & 1 deletion oauthenticator/_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""oauthenticator version info"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

Expand Down
4 changes: 2 additions & 2 deletions oauthenticator/auth0.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
c.JupyterHub.authenticator_class = 'oauthenticator.auth0.Auth0OAuthenticator'
"""

import json
import os

from jupyterhub.auth import LocalAuthenticator
from tornado.httpclient import HTTPRequest
from traitlets import Unicode, default
from traitlets import default
from traitlets import Unicode

from .oauth2 import OAuthenticator

Expand Down
4 changes: 2 additions & 2 deletions oauthenticator/azuread.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""
Custom Authenticator to use Azure AD with JupyterHub
"""

import os
import urllib
from distutils.version import LooseVersion as V

import jwt
from jupyterhub.auth import LocalAuthenticator
from tornado.httpclient import HTTPRequest
from traitlets import Unicode, default
from traitlets import default
from traitlets import Unicode

from .oauth2 import OAuthenticator

Expand Down
4 changes: 2 additions & 2 deletions oauthenticator/bitbucket.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""
Custom Authenticator to use Bitbucket OAuth with JupyterHub
"""

import urllib

from jupyterhub.auth import LocalAuthenticator
from tornado.httpclient import HTTPRequest
from tornado.httputil import url_concat
from traitlets import Set, default
from traitlets import default
from traitlets import Set

from .oauth2 import OAuthenticator

Expand Down
12 changes: 8 additions & 4 deletions oauthenticator/cilogon.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@
Use `c.CILogonOAuthenticator.username_claim = 'email'` to use
email instead of ePPN as the JupyterHub username.
"""

import os

from jupyterhub.auth import LocalAuthenticator
from tornado import web
from tornado.httpclient import HTTPRequest
from tornado.httputil import url_concat
from traitlets import Bool, List, Unicode, default, validate

from .oauth2 import OAuthenticator, OAuthLoginHandler
from traitlets import Bool
from traitlets import default
from traitlets import List
from traitlets import Unicode
from traitlets import validate

from .oauth2 import OAuthenticator
from .oauth2 import OAuthLoginHandler


class CILogonLoginHandler(OAuthLoginHandler):
Expand Down
11 changes: 8 additions & 3 deletions oauthenticator/generic.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
"""
Custom Authenticator to use generic OAuth2 with JupyterHub
"""

import base64
import os
from urllib.parse import urlencode

from jupyterhub.auth import LocalAuthenticator
from tornado.httpclient import AsyncHTTPClient, HTTPRequest
from tornado.httpclient import AsyncHTTPClient
from tornado.httpclient import HTTPRequest
from tornado.httputil import url_concat
from traitlets import Bool, Dict, List, Unicode, Union, default
from traitlets import Bool
from traitlets import default
from traitlets import Dict
from traitlets import List
from traitlets import Unicode
from traitlets import Union

from .oauth2 import OAuthenticator
from .traitlets import Callable
Expand Down
6 changes: 3 additions & 3 deletions oauthenticator/github.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""
Authenticator to use GitHub OAuth with JupyterHub
"""


import json
import os
import warnings
Expand All @@ -11,7 +9,9 @@
from tornado import web
from tornado.httpclient import HTTPRequest
from tornado.httputil import url_concat
from traitlets import Set, Unicode, default
from traitlets import default
from traitlets import Set
from traitlets import Unicode

from .oauth2 import OAuthenticator

Expand Down
7 changes: 4 additions & 3 deletions oauthenticator/gitlab.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""
Custom Authenticator to use GitLab OAuth with JupyterHub
"""


import json
import os
import warnings
Expand All @@ -12,7 +10,10 @@
from tornado.escape import url_escape
from tornado.httpclient import HTTPRequest
from tornado.httputil import url_concat
from traitlets import CUnicode, Set, Unicode, default
from traitlets import CUnicode
from traitlets import default
from traitlets import Set
from traitlets import Unicode

from .oauth2 import OAuthenticator

Expand Down
8 changes: 6 additions & 2 deletions oauthenticator/globus.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
from jupyterhub.utils import url_path_join
from tornado.httpclient import HTTPRequest
from tornado.web import HTTPError
from traitlets import Bool, List, Unicode, default
from traitlets import Bool
from traitlets import default
from traitlets import List
from traitlets import Unicode

from .oauth2 import OAuthenticator, OAuthLogoutHandler
from .oauth2 import OAuthenticator
from .oauth2 import OAuthLogoutHandler


class GlobusLogoutHandler(OAuthLogoutHandler):
Expand Down
11 changes: 8 additions & 3 deletions oauthenticator/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@
Derived from the GitHub OAuth authenticator.
"""

import os
import urllib.parse

from jupyterhub.auth import LocalAuthenticator
from jupyterhub.crypto import EncryptionUnavailable, InvalidToken, decrypt
from jupyterhub.crypto import decrypt
from jupyterhub.crypto import EncryptionUnavailable
from jupyterhub.crypto import InvalidToken
from tornado.auth import GoogleOAuth2Mixin
from tornado.httpclient import HTTPRequest
from tornado.httputil import url_concat
from tornado.web import HTTPError
from traitlets import Dict, List, Unicode, default, validate
from traitlets import default
from traitlets import Dict
from traitlets import List
from traitlets import Unicode
from traitlets import validate

from .oauth2 import OAuthenticator

Expand Down
11 changes: 7 additions & 4 deletions oauthenticator/mediawiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@
Requires `mwoauth` package.
"""

import json
import os
from asyncio import wrap_future
from concurrent.futures import ThreadPoolExecutor

from jupyterhub.handlers import BaseHandler
from jupyterhub.utils import url_path_join
from mwoauth import ConsumerToken, Handshaker
from mwoauth import ConsumerToken
from mwoauth import Handshaker
from mwoauth.tokens import RequestToken
from traitlets import Any, Integer, Unicode
from traitlets import Any
from traitlets import Integer
from traitlets import Unicode

from oauthenticator import OAuthCallbackHandler, OAuthenticator
from oauthenticator import OAuthCallbackHandler
from oauthenticator import OAuthenticator

# Name of cookie used to pass auth token between the oauth
# login and authentication phase
Expand Down
18 changes: 13 additions & 5 deletions oauthenticator/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,29 @@
Most of the code c/o Kyle Kelley (@rgbkrk)
"""

import base64
import json
import os
import uuid
from urllib.parse import quote, urlparse, urlunparse
from urllib.parse import quote
from urllib.parse import urlparse
from urllib.parse import urlunparse

from jupyterhub.auth import Authenticator
from jupyterhub.handlers import BaseHandler, LogoutHandler
from jupyterhub.handlers import BaseHandler
from jupyterhub.handlers import LogoutHandler
from jupyterhub.utils import url_path_join
from tornado import web
from tornado.auth import OAuth2Mixin
from tornado.httpclient import AsyncHTTPClient, HTTPClientError
from tornado.httpclient import AsyncHTTPClient
from tornado.httpclient import HTTPClientError
from tornado.log import app_log
from traitlets import Any, Bool, Dict, List, Unicode, default
from traitlets import Any
from traitlets import Bool
from traitlets import default
from traitlets import Dict
from traitlets import List
from traitlets import Unicode


def guess_callback_uri(protocol, host, hub_server_url):
Expand Down
1 change: 0 additions & 1 deletion oauthenticator/okpy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Custom Authenticator to use okpy OAuth with JupyterHub
"""

from binascii import a2b_base64

from jupyterhub.auth import LocalAuthenticator
Expand Down
6 changes: 4 additions & 2 deletions oauthenticator/openshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
Derived from the GitHub OAuth authenticator.
"""

import os

import requests
from jupyterhub.auth import LocalAuthenticator
from tornado.httpclient import HTTPRequest
from tornado.httputil import url_concat
from traitlets import Bool, Set, Unicode, default
from traitlets import Bool
from traitlets import default
from traitlets import Set
from traitlets import Unicode

from oauthenticator.oauth2 import OAuthenticator

Expand Down
5 changes: 2 additions & 3 deletions oauthenticator/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""Py.Test fixtures"""

import inspect

from tornado.httpclient import AsyncHTTPClient
from pytest import fixture
from tornado import ioloop
from tornado.httpclient import AsyncHTTPClient
from tornado.platform.asyncio import AsyncIOMainLoop
from pytest import fixture

from .mocks import MockAsyncHTTPClient

Expand Down
11 changes: 5 additions & 6 deletions oauthenticator/tests/mocks.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
"""Mocking utilities for testing"""

from io import BytesIO
import json
import os
import re
from unittest.mock import Mock
from urllib.parse import urlparse, parse_qs
import uuid
from io import BytesIO
from unittest.mock import Mock
from urllib.parse import parse_qs
from urllib.parse import urlparse

import pytest

from tornado import web
from tornado.httpclient import HTTPResponse
from tornado.httputil import HTTPServerRequest
from tornado.log import app_log
from tornado.simple_httpclient import SimpleAsyncHTTPClient
from tornado import web

RegExpType = type(re.compile('.'))

Expand Down
3 changes: 2 additions & 1 deletion oauthenticator/tests/test_auth0.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
from unittest.mock import patch

from pytest import fixture, mark
from pytest import fixture
from pytest import mark

from ..auth0 import Auth0OAuthenticator
from .mocks import setup_oauth_mock
Expand Down
Loading

0 comments on commit 95e4464

Please sign in to comment.