Browse Source

pep8: run on social_auth

David Cramer 7 years ago
parent
commit
0d7e13aceb

+ 1 - 1
src/social_auth/backends/asana.py

@@ -61,7 +61,7 @@ class AsanaAuth(BaseOAuth2):
         params = self.auth_complete_params(self.validate_state())
         try:
             response = requests.post(self.ACCESS_TOKEN_URL, data=params,
-                              headers=self.auth_headers())
+                                     headers=self.auth_headers())
             response.raise_for_status()
         except requests.exceptions.HTTPError as e:
             if e.code == 400:

+ 1 - 1
src/social_auth/context_processors.py

@@ -50,7 +50,7 @@ def social_auth_by_name_backends(request):
         user = request.user
         if hasattr(user, 'is_authenticated') and user.is_authenticated():
             accounts.update((assoc.provider, assoc)
-                    for assoc in UserSocialAuth.get_social_auth_for_user(user))
+                            for assoc in UserSocialAuth.get_social_auth_for_user(user))
         return accounts
     return {'social_auth': LazyDict(context_value)}
 

+ 10 - 0
src/social_auth/exceptions.py

@@ -26,12 +26,14 @@ class StopPipeline(SocialAuthBaseException):
     """Stop pipeline process exception.
     Raise this exception to stop the rest of the pipeline process.
     """
+
     def __unicode__(self):
         return ugettext(u'Stop pipeline')
 
 
 class AuthException(SocialAuthBaseException):
     """Auth process exception."""
+
     def __init__(self, backend, *args, **kwargs):
         self.backend = backend
         super(AuthException, self).__init__(*args, **kwargs)
@@ -39,6 +41,7 @@ class AuthException(SocialAuthBaseException):
 
 class AuthFailed(AuthException):
     """Auth process failed for some reason."""
+
     def __unicode__(self):
         if self.message == 'access_denied':
             return ugettext(u'Authentication process was cancelled')
@@ -49,12 +52,14 @@ class AuthFailed(AuthException):
 
 class AuthCanceled(AuthException):
     """Auth process was canceled by user."""
+
     def __unicode__(self):
         return ugettext(u'Authentication process canceled')
 
 
 class AuthUnknownError(AuthException):
     """Unknown auth process error."""
+
     def __unicode__(self):
         err = u'An unknown error happened while authenticating %s'
         return ugettext(err) % super(AuthUnknownError, self).__unicode__()
@@ -62,6 +67,7 @@ class AuthUnknownError(AuthException):
 
 class AuthTokenError(AuthException):
     """Auth token error."""
+
     def __unicode__(self):
         msg = super(AuthTokenError, self).__unicode__()
         return ugettext(u'Token error: %s') % msg
@@ -69,6 +75,7 @@ class AuthTokenError(AuthException):
 
 class AuthMissingParameter(AuthException):
     """Missing parameter needed to start or complete the process."""
+
     def __init__(self, backend, parameter, *args, **kwargs):
         self.parameter = parameter
         super(AuthMissingParameter, self).__init__(backend, *args, **kwargs)
@@ -79,17 +86,20 @@ class AuthMissingParameter(AuthException):
 
 class AuthStateMissing(AuthException):
     """State parameter is incorrect."""
+
     def __unicode__(self):
         return ugettext(u'Session value state missing.')
 
 
 class AuthStateForbidden(AuthException):
     """State parameter is incorrect."""
+
     def __unicode__(self):
         return ugettext(u'Wrong state parameter given.')
 
 
 class AuthTokenRevoked(AuthException):
     """User revoked the access_token in the provider."""
+
     def __unicode__(self):
         return ugettext(u'User revoke access to the token')

+ 1 - 0
src/social_auth/fields.py

@@ -13,6 +13,7 @@ class JSONField(models.TextField):
     """Simple JSON field that stores python structures as JSON strings
     on database.
     """
+
     def to_python(self, value):
         """
         Convert the input JSON value into python structures, raises

+ 1 - 0
src/social_auth/middleware.py

@@ -21,6 +21,7 @@ class SocialAuthExceptionMiddleware(object):
     This middleware can be extended by overriding the get_message or
     get_redirect_uri methods, which each accept request and exception.
     """
+
     def process_exception(self, request, exception):
         self.backend = self.get_backend(request, exception)
         if self.raise_exception(request, exception):

+ 21 - 15
src/social_auth/south_migrations/0001_initial.py

@@ -19,25 +19,33 @@ class Migration(SchemaMigration):
 
     def forwards(self, orm):
         # Adding model 'UserSocialAuth'
-        db.create_table('social_auth_usersocialauth', (
-            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
-            ('user', self.gf('django.db.models.fields.related.ForeignKey')(related_name='social_auth', to=orm[USER_MODEL])),
-            ('provider', self.gf('django.db.models.fields.CharField')(max_length=32)),
-            ('uid', self.gf('django.db.models.fields.CharField')(max_length=UID_LENGTH)),
-            ('extra_data', self.gf('social_auth.fields.JSONField')(default='{}')),
-        ))
+        db.create_table(
+            'social_auth_usersocialauth', (('id', self.gf('django.db.models.fields.AutoField')(
+                primary_key=True)), ('user', self.gf('django.db.models.fields.related.ForeignKey')(
+                    related_name='social_auth', to=orm[USER_MODEL])), ('provider', self.gf('django.db.models.fields.CharField')(
+                        max_length=32)), ('uid', self.gf('django.db.models.fields.CharField')(
+                            max_length=UID_LENGTH)), ('extra_data', self.gf('social_auth.fields.JSONField')(
+                                default='{}')), ))
         db.send_create_signal('social_auth', ['UserSocialAuth'])
 
         # Adding unique constraint on 'UserSocialAuth', fields ['provider', 'uid']
         db.create_unique('social_auth_usersocialauth', ['provider', 'uid'])
 
         # Adding model 'Nonce'
-        db.create_table('social_auth_nonce', (
-            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
-            ('server_url', self.gf('django.db.models.fields.CharField')(max_length=NONCE_SERVER_URL_LENGTH)),
-            ('timestamp', self.gf('django.db.models.fields.IntegerField')()),
-            ('salt', self.gf('django.db.models.fields.CharField')(max_length=40)),
-        ))
+        db.create_table(
+            'social_auth_nonce',
+            (('id',
+              self.gf('django.db.models.fields.AutoField')(
+                  primary_key=True)),
+                ('server_url',
+                 self.gf('django.db.models.fields.CharField')(
+                     max_length=NONCE_SERVER_URL_LENGTH)),
+                ('timestamp',
+                 self.gf('django.db.models.fields.IntegerField')()),
+                ('salt',
+                 self.gf('django.db.models.fields.CharField')(
+                     max_length=40)),
+             ))
         db.send_create_signal('social_auth', ['Nonce'])
 
         # Adding model 'Association'
@@ -52,7 +60,6 @@ class Migration(SchemaMigration):
         ))
         db.send_create_signal('social_auth', ['Association'])
 
-
     def backwards(self, orm):
         # Removing unique constraint on 'UserSocialAuth', fields ['provider', 'uid']
         db.delete_unique('social_auth_usersocialauth', ['provider', 'uid'])
@@ -66,7 +73,6 @@ class Migration(SchemaMigration):
         # Deleting model 'Association'
         db.delete_table('social_auth_association')
 
-
     models = {
         'auth.group': {
             'Meta': {'object_name': 'Group'},

+ 0 - 1
src/social_auth/south_migrations/0002_auto__add_unique_nonce_timestamp_salt_server_url__add_unique_associati.py

@@ -43,7 +43,6 @@ class Migration(SchemaMigration):
         # Removing index on 'Nonce', fields ['timestamp']
         db.delete_index('social_auth_nonce', ['timestamp'])
 
-
     models = {
         'auth.group': {
             'Meta': {'object_name': 'Group'},

+ 1 - 3
src/social_auth/south_migrations/0003_auto__del_nonce__del_unique_nonce_server_url_timestamp_salt__del_assoc.py

@@ -20,7 +20,6 @@ class Migration(SchemaMigration):
         # Deleting model 'Association'
         db.delete_table(u'social_auth_association')
 
-
     def backwards(self, orm):
         # Adding model 'Nonce'
         db.create_table(u'social_auth_nonce', (
@@ -49,7 +48,6 @@ class Migration(SchemaMigration):
         # Adding unique constraint on 'Association', fields ['server_url', 'handle']
         db.create_unique(u'social_auth_association', ['server_url', 'handle'])
 
-
     models = {
         'sentry.user': {
             'Meta': {'object_name': 'User', 'db_table': "'auth_user'"},
@@ -77,4 +75,4 @@ class Migration(SchemaMigration):
         }
     }
 
-    complete_apps = ['social_auth']
+    complete_apps = ['social_auth']

+ 1 - 3
src/social_auth/south_migrations/0004_auto__del_unique_usersocialauth_provider_uid__add_unique_usersocialaut.py

@@ -14,7 +14,6 @@ class Migration(SchemaMigration):
         # Adding unique constraint on 'UserSocialAuth', fields ['provider', 'uid', 'user']
         db.create_unique(u'social_auth_usersocialauth', ['provider', 'uid', 'user_id'])
 
-
     def backwards(self, orm):
         # Removing unique constraint on 'UserSocialAuth', fields ['provider', 'uid', 'user']
         db.delete_unique(u'social_auth_usersocialauth', ['provider', 'uid', 'user_id'])
@@ -22,7 +21,6 @@ class Migration(SchemaMigration):
         # Adding unique constraint on 'UserSocialAuth', fields ['provider', 'uid']
         db.create_unique(u'social_auth_usersocialauth', ['provider', 'uid'])
 
-
     models = {
         'sentry.user': {
             'Meta': {'object_name': 'User', 'db_table': "'auth_user'"},
@@ -50,4 +48,4 @@ class Migration(SchemaMigration):
         }
     }
 
-    complete_apps = ['social_auth']
+    complete_apps = ['social_auth']

+ 6 - 6
src/social_auth/urls.py

@@ -10,9 +10,9 @@ from social_auth.views import auth, complete
 
 
 urlpatterns = patterns('',
-    # authentication
-    url(r'^associate/(?P<backend>[^/]+)/$', auth,
-        name='socialauth_associate'),
-    url(r'^associate/complete/(?P<backend>[^/]+)/$', complete,
-        name='socialauth_associate_complete'),
-)
+                       # authentication
+                       url(r'^associate/(?P<backend>[^/]+)/$', auth,
+                           name='socialauth_associate'),
+                       url(r'^associate/complete/(?P<backend>[^/]+)/$', complete,
+                           name='socialauth_associate_complete'),
+                       )

Some files were not shown because too many files changed in this diff