aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPat Ferate <pferate+github@gmail.com>2016-07-08 13:31:15 -0700
committerPat Ferate <pferate+github@gmail.com>2016-07-11 08:13:53 -0700
commit6b6c56d3ee60c749f74f746300934e3ae18c56c1 (patch)
tree8f89b057b82a748530feededb879850989d29557
parent8eb3aa2f955dd4ad31aeb3cb1e43c783aaebb85a (diff)
downloadoauth2client-6b6c56d3ee60c749f74f746300934e3ae18c56c1.tar.gz
More general PEP8 cleanup
-rw-r--r--docs/conf.py23
-rw-r--r--oauth2client/contrib/django_util/__init__.py10
-rw-r--r--oauth2client/contrib/django_util/decorators.py2
-rw-r--r--oauth2client/service_account.py4
-rw-r--r--samples/googleappengine/call_compute_service_from_gae.py2
-rw-r--r--scripts/run_system_tests.py4
-rw-r--r--setup.py7
-rw-r--r--tests/contrib/test_flask_util.py3
-rw-r--r--tests/test_jwt.py5
9 files changed, 30 insertions, 30 deletions
diff --git a/docs/conf.py b/docs/conf.py
index f84911c..4afcfe0 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -10,9 +10,17 @@ import sys
import mock
-# See
-# (https://read-the-docs.readthedocs.io/en/latest/faq.html#\
-# i-get-import-errors-on-libraries-that-depend-on-c-modules)
+# In order to load django before 1.7, we need to create a faux
+# settings module and load it. This assumes django has been installed
+# (but it must be for the docs to build), so if it has not already
+# been installed run `pip install -r docs/requirements.txt`.
+os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.contrib.test_django_settings'
+import django
+if django.VERSION[1] < 7:
+ sys.path.insert(0, '.')
+
+# See https://read-the-docs.readthedocs.io/en/latest/faq.html#i-get-import-errors-on-libraries-that-depend-on-c-modules
+
class Mock(mock.Mock):
@@ -61,15 +69,6 @@ release = distro.version
exclude_patterns = ['_build']
-# In order to load django before 1.7, we need to create a faux
-# settings module and load it. This assumes django has been installed
-# (but it must be for the docs to build), so if it has not already
-# been installed run `pip install -r docs/requirements.txt`.
-os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.contrib.test_django_settings'
-import django
-if django.VERSION[1] < 7:
- sys.path.insert(0, '.')
-
# -- Options for HTML output ----------------------------------------------
# We fake our more expensive imports when building the docs.
diff --git a/oauth2client/contrib/django_util/__init__.py b/oauth2client/contrib/django_util/__init__.py
index 4ede05b..a9dfb39 100644
--- a/oauth2client/contrib/django_util/__init__.py
+++ b/oauth2client/contrib/django_util/__init__.py
@@ -124,8 +124,9 @@ To make OAuth2 optional and provide an authorization link in your own views.
return HttpResponse("User email: %s"
% request.oauth.credentials.id_token['email'])
else:
- return HttpResponse('Here is an OAuth Authorize link:
- <a href="%s">Authorize</a>' % request.oauth.get_authorize_redirect())
+ return HttpResponse(
+ 'Here is an OAuth Authorize link: <a href="%s">Authorize</a>'
+ % request.oauth.get_authorize_redirect())
If a view needs a scope not included in the default scopes specified in
the settings, you can use [incremental auth](https://developers.google.com/identity/sign-in/web/incremental-auth)
@@ -144,8 +145,9 @@ and specify additional scopes in the decorator arguments.
events = service.files().list().execute()['items']
return HttpResponse(str(events))
else:
- return HttpResponse('Here is an OAuth Authorize link:
- <a href="%s">Authorize</a>' % request.oauth.get_authorize_redirect())
+ return HttpResponse(
+ 'Here is an OAuth Authorize link: <a href="%s">Authorize</a>'
+ % request.oauth.get_authorize_redirect())
To provide a callback on authorization being completed, use the
diff --git a/oauth2client/contrib/django_util/decorators.py b/oauth2client/contrib/django_util/decorators.py
index 0e0a4b2..214f867 100644
--- a/oauth2client/contrib/django_util/decorators.py
+++ b/oauth2client/contrib/django_util/decorators.py
@@ -36,7 +36,7 @@ def oauth_required(decorated_function=None, scopes=None, **decorator_kwargs):
developerKey=API_KEY)
events = service.events().list(
calendarId='primary').execute()['items']
- return HttpResponse("email: %s , calendar: %s" % (email, str(events)))
+ return HttpResponse("email: %s, calendar: %s" % (email, str(events)))
:param decorated_function: View function to decorate, must have the Django
request object as the first argument
diff --git a/oauth2client/service_account.py b/oauth2client/service_account.py
index 8cc3505..57b4856 100644
--- a/oauth2client/service_account.py
+++ b/oauth2client/service_account.py
@@ -604,8 +604,8 @@ class _JWTAccessCredentials(ServiceAccountCredentials):
h = credentials.authorize(h)
"""
request_orig = http.request
- request_auth = super(_JWTAccessCredentials,
- self).authorize(http).request
+ request_auth = super(
+ _JWTAccessCredentials, self).authorize(http).request
# The closure that will replace 'httplib2.Http.request'.
def new_request(uri, method='GET', body=None, headers=None,
diff --git a/samples/googleappengine/call_compute_service_from_gae.py b/samples/googleappengine/call_compute_service_from_gae.py
index b1b1000..5c7fa33 100644
--- a/samples/googleappengine/call_compute_service_from_gae.py
+++ b/samples/googleappengine/call_compute_service_from_gae.py
@@ -23,4 +23,4 @@ class MainPage(webapp2.RequestHandler):
self.response.write(get_instances())
-app = webapp2.WSGIApplication([('/', MainPage),], debug=True)
+app = webapp2.WSGIApplication([('/', MainPage), ], debug=True)
diff --git a/scripts/run_system_tests.py b/scripts/run_system_tests.py
index f955e3b..74d27d9 100644
--- a/scripts/run_system_tests.py
+++ b/scripts/run_system_tests.py
@@ -36,8 +36,8 @@ USER_INFO = 'https://www.googleapis.com/oauth2/v2/userinfo'
def _require_environ():
if (JSON_KEY_PATH is None or P12_KEY_PATH is None or
- P12_KEY_EMAIL is None or USER_KEY_PATH is None or
- USER_KEY_EMAIL is None):
+ P12_KEY_EMAIL is None or USER_KEY_PATH is None or
+ USER_KEY_EMAIL is None):
raise EnvironmentError('Expected environment variables to be set:',
'OAUTH2CLIENT_TEST_JSON_KEY_PATH',
'OAUTH2CLIENT_TEST_P12_KEY_PATH',
diff --git a/setup.py b/setup.py
index ef6e2e1..36894a8 100644
--- a/setup.py
+++ b/setup.py
@@ -20,6 +20,9 @@ are not already installed.
from __future__ import print_function
import sys
+from setuptools import find_packages
+from setuptools import setup
+import oauth2client
if sys.version_info < (2, 6):
print('oauth2client requires python2 version >= 2.6.', file=sys.stderr)
@@ -28,9 +31,6 @@ if (3, 1) <= sys.version_info < (3, 3):
print('oauth2client requires python3 version >= 3.3.', file=sys.stderr)
sys.exit(1)
-from setuptools import find_packages
-from setuptools import setup
-
install_requires = [
'httplib2>=0.9.1',
'pyasn1>=0.1.7',
@@ -41,7 +41,6 @@ install_requires = [
long_desc = """The oauth2client is a client library for OAuth 2.0."""
-import oauth2client
version = oauth2client.__version__
setup(
diff --git a/tests/contrib/test_flask_util.py b/tests/contrib/test_flask_util.py
index f4fe0e9..f08d229 100644
--- a/tests/contrib/test_flask_util.py
+++ b/tests/contrib/test_flask_util.py
@@ -474,7 +474,8 @@ class FlaskOAuth2Tests(unittest2.TestCase):
# Starting the authorization flow should include the
# include_granted_scopes parameter as well as the scopes.
response = client.get(response.headers['Location'][17:])
- q = urlparse.parse_qs(response.headers['Location'].split('?', 1)[1])
+ q = urlparse.parse_qs(
+ response.headers['Location'].split('?', 1)[1])
self.assertIn('include_granted_scopes', q)
self.assertEqual(
set(q['scope'][0].split(' ')),
diff --git a/tests/test_jwt.py b/tests/test_jwt.py
index f567f5d..00c8ef7 100644
--- a/tests/test_jwt.py
+++ b/tests/test_jwt.py
@@ -147,15 +147,14 @@ class CryptTests(unittest2.TestCase):
def test_verify_id_token_with_certs_uri_fails(self):
jwt = self._create_signed_jwt()
+ test_email = 'some_audience_address@testing.gserviceaccount.com'
http = HttpMockSequence([
({'status': '404'}, datafile('certs.json')),
])
with self.assertRaises(VerifyJwtTokenError):
- verify_id_token(jwt,
- 'some_audience_address@testing.gserviceaccount.com',
- http=http)
+ verify_id_token(jwt, test_email, http=http)
def test_verify_id_token_bad_tokens(self):
private_key = datafile('privatekey.' + self.format_)