From 389ed3328def75bcac26c65e2d6e70dc93041d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Pito=C5=84?= Date: Sun, 26 Feb 2017 21:47:09 +0100 Subject: [PATCH] #702: further fixes in dicts fixer --- extras/fixdictsformatting.py | 7 +++++++ misago/threads/api/threadendpoints/merge.py | 5 ++++- misago/threads/migrations/0003_attachment_types.py | 4 +++- misago/threads/search.py | 4 ++-- misago/users/djangoadmin.py | 2 +- misago/users/forms/auth.py | 7 ++----- misago/users/migrations/0002_users_settings.py | 4 +--- misago/users/migrations/0006_update_settings.py | 4 +--- misago/users/views/activation.py | 4 +++- misago/users/views/options.py | 4 ++-- 10 files changed, 26 insertions(+), 19 deletions(-) diff --git a/extras/fixdictsformatting.py b/extras/fixdictsformatting.py index c6a090e5ad..f27b0a980b 100644 --- a/extras/fixdictsformatting.py +++ b/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 isinstance(node, Leaf): 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 if is_followup: new_value = node.value diff --git a/misago/threads/api/threadendpoints/merge.py b/misago/threads/api/threadendpoints/merge.py index 4710f94e6b..223638db64 100644 --- a/misago/threads/api/threadendpoints/merge.py +++ b/misago/threads/api/threadendpoints/merge.py @@ -192,7 +192,10 @@ def merge_threads(request, validated_data, threads, poll): thread.delete() record_event( - request, new_thread, 'merged', { + request, + new_thread, + 'merged', + { 'merged_thread': thread.title, }, commit=False, diff --git a/misago/threads/migrations/0003_attachment_types.py b/misago/threads/migrations/0003_attachment_types.py index 2c08bbb05c..4d6d9efdd2 100644 --- a/misago/threads/migrations/0003_attachment_types.py +++ b/misago/threads/migrations/0003_attachment_types.py @@ -27,7 +27,9 @@ { 'name': '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 }, { diff --git a/misago/threads/search.py b/misago/threads/search.py index e687f0bde8..7f6ea083fa 100644 --- a/misago/threads/search.py +++ b/misago/threads/search.py @@ -47,8 +47,8 @@ def search(self, query, page=1): results = { 'results': FeedSerializer(posts, many=True, context={ - 'user': self.request.user, - }).data + 'user': self.request.user, + }).data } results.update(paginator) diff --git a/misago/users/djangoadmin.py b/misago/users/djangoadmin.py index befc82dd09..4613f7315f 100644 --- a/misago/users/djangoadmin.py +++ b/misago/users/djangoadmin.py @@ -82,7 +82,7 @@ class UserAdmin(admin.ModelAdmin): { 'fields': ( 'username', 'email', 'rank', 'last_login', 'joined_on', 'is_staff', - 'is_superuser', 'edit_from_misago_link', + 'is_superuser', 'edit_from_misago_link', ) }, ], diff --git a/misago/users/forms/auth.py b/misago/users/forms/auth.py index 135cf71037..0228cec476 100644 --- a/misago/users/forms/auth.py +++ b/misago/users/forms/auth.py @@ -15,12 +15,9 @@ class MisagoAuthMixin(object): error_messages = { 'empty_data': _("Fill out both fields."), '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': _( - "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." ), } diff --git a/misago/users/migrations/0002_users_settings.py b/misago/users/migrations/0002_users_settings.py index e489266ba7..2ede609e45 100644 --- a/misago/users/migrations/0002_users_settings.py +++ b/misago/users/migrations/0002_users_settings.py @@ -118,9 +118,7 @@ def create_users_settings_group(apps, schema_editor): { 'setting': 'avatar_upload_limit', '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', 'value': 1536, 'field_extra': { diff --git a/misago/users/migrations/0006_update_settings.py b/misago/users/migrations/0006_update_settings.py index 9b30855aed..a4c23d9489 100644 --- a/misago/users/migrations/0006_update_settings.py +++ b/misago/users/migrations/0006_update_settings.py @@ -104,9 +104,7 @@ def update_users_settings(apps, schema_editor): { 'setting': 'avatar_upload_limit', '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', 'default_value': 1536, 'field_extra': { diff --git a/misago/users/views/activation.py b/misago/users/views/activation.py index 4d6fd64c41..5bf8fde3a6 100644 --- a/misago/users/views/activation.py +++ b/misago/users/views/activation.py @@ -62,7 +62,9 @@ def activate_by_token(request, pk, token): }) except ActivationError as e: return render( - request, 'misago/activation/error.html', { + request, + 'misago/activation/error.html', + { 'message': e.args[0], }, status=400, diff --git a/misago/users/views/options.py b/misago/users/views/options.py index df11e51992..44f8f22ed5 100644 --- a/misago/users/views/options.py +++ b/misago/users/views/options.py @@ -55,8 +55,8 @@ def confirm_email_change(request, token): return render( request, 'misago/options/credentials_changed.html', { 'message': message % { - 'user': request.user.username, - }, + 'user': request.user.username, + }, } )