Browse Source

#702: further fixes in dicts fixer

Rafał Pitoń 8 years ago
parent
commit
389ed3328d

+ 7 - 0
extras/fixdictsformatting.py

@@ -83,6 +83,13 @@ def walk_dedent_tree_node(node, children, force_split_next=False):
     if six.text_type(node).startswith("\n"):
     if six.text_type(node).startswith("\n"):
         if isinstance(node, Leaf):
         if isinstance(node, Leaf):
             prev = node.prev_sibling
             prev = node.prev_sibling
+            next = node.next_sibling
+
+            if next and six.text_type(next).strip() == ':':
+                return # excape hatch for misidentification of single nested dict item
+            if six.text_type(node).strip() == '}':
+                return # generally yapf does good job positioning closing curlybraces
+
             is_followup = prev and prev.type == token.STRING and node.type == token.STRING
             is_followup = prev and prev.type == token.STRING and node.type == token.STRING
             if is_followup:
             if is_followup:
                 new_value = node.value
                 new_value = node.value

+ 4 - 1
misago/threads/api/threadendpoints/merge.py

@@ -192,7 +192,10 @@ def merge_threads(request, validated_data, threads, poll):
         thread.delete()
         thread.delete()
 
 
         record_event(
         record_event(
-            request, new_thread, 'merged', {
+            request,
+            new_thread,
+            'merged',
+            {
                 'merged_thread': thread.title,
                 'merged_thread': thread.title,
             },
             },
             commit=False,
             commit=False,

+ 3 - 1
misago/threads/migrations/0003_attachment_types.py

@@ -27,7 +27,9 @@ ATTACHMENTS = [
     {
     {
         'name': 'PDF',
         'name': 'PDF',
         'extensions': ('pdf', ),
         'extensions': ('pdf', ),
-        'mimetypes': ('application/pdf', 'application/x-pdf', 'application/x-bzpdf', 'application/x-gzpdf',),
+        'mimetypes': (
+            'application/pdf', 'application/x-pdf', 'application/x-bzpdf', 'application/x-gzpdf',
+        ),
         'size_limit': 4 * 1024
         'size_limit': 4 * 1024
     },
     },
     {
     {

+ 2 - 2
misago/threads/search.py

@@ -47,8 +47,8 @@ class SearchThreads(SearchProvider):
 
 
         results = {
         results = {
             'results': FeedSerializer(posts, many=True, context={
             'results': FeedSerializer(posts, many=True, context={
-                'user': self.request.user,
-            }).data
+            'user': self.request.user,
+        }).data
         }
         }
         results.update(paginator)
         results.update(paginator)
 
 

+ 1 - 1
misago/users/djangoadmin.py

@@ -82,7 +82,7 @@ class UserAdmin(admin.ModelAdmin):
             {
             {
                 'fields': (
                 'fields': (
                     'username', 'email', 'rank', 'last_login', 'joined_on', 'is_staff',
                     'username', 'email', 'rank', 'last_login', 'joined_on', 'is_staff',
-                    'is_superuser', 'edit_from_misago_link',
+                'is_superuser', 'edit_from_misago_link',
                 )
                 )
             },
             },
         ],
         ],

+ 2 - 5
misago/users/forms/auth.py

@@ -15,12 +15,9 @@ class MisagoAuthMixin(object):
     error_messages = {
     error_messages = {
         'empty_data': _("Fill out both fields."),
         'empty_data': _("Fill out both fields."),
         'invalid_login': _("Login or password is incorrect."),
         'invalid_login': _("Login or password is incorrect."),
-        'inactive_user': _(
-            "You have to activate your account before you will be able to sign in."
-        ),
+        'inactive_user': _("You have to activate your account before you will be able to sign in."),
         'inactive_admin': _(
         'inactive_admin': _(
-            "Your account has to be activated by Administrator "
-            "before you will be able to sign in."
+            "Your account has to be activated by Administrator before you will be able to sign in."
         ),
         ),
     }
     }
 
 

+ 1 - 3
misago/users/migrations/0002_users_settings.py

@@ -118,9 +118,7 @@ def create_users_settings_group(apps, schema_editor):
                 {
                 {
                     'setting': 'avatar_upload_limit',
                     'setting': 'avatar_upload_limit',
                     'name': _("Maximum size of uploaded avatar"),
                     'name': _("Maximum size of uploaded avatar"),
-                    'description': _(
-                        "Enter maximum allowed file size (in KB) for avatar uploads."
-                    ),
+                    'description': _("Enter maximum allowed file size (in KB) for avatar uploads."),
                     'python_type': 'int',
                     'python_type': 'int',
                     'value': 1536,
                     'value': 1536,
                     'field_extra': {
                     'field_extra': {

+ 1 - 3
misago/users/migrations/0006_update_settings.py

@@ -104,9 +104,7 @@ def update_users_settings(apps, schema_editor):
                 {
                 {
                     'setting': 'avatar_upload_limit',
                     'setting': 'avatar_upload_limit',
                     'name': _("Maximum size of uploaded avatar"),
                     'name': _("Maximum size of uploaded avatar"),
-                    'description': _(
-                        "Enter maximum allowed file size (in KB) for avatar uploads."
-                    ),
+                    'description': _("Enter maximum allowed file size (in KB) for avatar uploads."),
                     'python_type': 'int',
                     'python_type': 'int',
                     'default_value': 1536,
                     'default_value': 1536,
                     'field_extra': {
                     'field_extra': {

+ 3 - 1
misago/users/views/activation.py

@@ -62,7 +62,9 @@ def activate_by_token(request, pk, token):
         })
         })
     except ActivationError as e:
     except ActivationError as e:
         return render(
         return render(
-            request, 'misago/activation/error.html', {
+            request,
+            'misago/activation/error.html',
+            {
                 'message': e.args[0],
                 'message': e.args[0],
             },
             },
             status=400,
             status=400,

+ 2 - 2
misago/users/views/options.py

@@ -55,8 +55,8 @@ def confirm_email_change(request, token):
     return render(
     return render(
         request, 'misago/options/credentials_changed.html', {
         request, 'misago/options/credentials_changed.html', {
             'message': message % {
             'message': message % {
-            'user': request.user.username,
-        },
+                'user': request.user.username,
+            },
         }
         }
     )
     )