diff --git a/tools/documentation_crawler/documentation_crawler/spiders/common/spiders.py b/tools/documentation_crawler/documentation_crawler/spiders/common/spiders.py index 9fc29e92fb..6449363482 100644 --- a/tools/documentation_crawler/documentation_crawler/spiders/common/spiders.py +++ b/tools/documentation_crawler/documentation_crawler/spiders/common/spiders.py @@ -45,8 +45,10 @@ VNU_IGNORE = [ r"The first occurrence of ID “[^”]*” was here\.", r"Attribute “markdown” not allowed on element “div” at this point\.", r"No “p” element in scope but a “p” end tag seen\.", - r"Element “div” not allowed as child of element “ul” in this context\. " - + r"\(Suppressing further errors from this subtree\.\)", + ( + r"Element “div” not allowed as child of element “ul” in this context\." + r" \(Suppressing further errors from this subtree\.\)" + ), # Opinionated informational messages. r"Self-closing tag syntax in text/html documents is widely discouraged; it’s unnecessary and interacts badly with other HTML features \(e\.g\., unquoted attribute values\)\. If you’re using a tool that injects self-closing tag syntax into all void elements, without any option to prevent it from doing so, then consider switching to a different tool\.", ] diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py index 440d32588f..52703840fc 100644 --- a/tools/linter_lib/custom_check.py +++ b/tools/linter_lib/custom_check.py @@ -673,9 +673,7 @@ html_rules: List["Rule"] = [ { "pattern": "style ?=", "description": "Avoid using the `style=` attribute; we prefer styling in CSS files", - "exclude_pattern": r'.*style ?=["' - + "'" - + "](display: ?none|background: {{|color: {{|background-color: {{).*", + "exclude_pattern": r""".*style ?=["'](display: ?none|background: {{|color: {{|background-color: {{).*""", "exclude": { # 5xx page doesn't have external CSS "static/html/5xx.html", diff --git a/zerver/forms.py b/zerver/forms.py index cf72ea25aa..ea3a8dfbfd 100644 --- a/zerver/forms.py +++ b/zerver/forms.py @@ -52,15 +52,15 @@ if settings.BILLING_ENABLED: # We don't mark this error for translation, because it's displayed # only to MIT users. MIT_VALIDATION_ERROR = ( - "That user does not exist at MIT or is a " - + 'mailing list. ' - + "If you want to sign up an alias for Zulip, " - + 'contact us.' + "That user does not exist at MIT or is a" + ' mailing list.' + " If you want to sign up an alias for Zulip," + ' contact us.' ) DEACTIVATED_ACCOUNT_ERROR = gettext_lazy( - "Your account {username} has been deactivated. " - + "Please contact your organization administrator to reactivate it." + "Your account {username} has been deactivated." + " Please contact your organization administrator to reactivate it." ) PASSWORD_TOO_WEAK_ERROR = gettext_lazy("The password is too weak.") @@ -451,9 +451,9 @@ class OurAuthenticationForm(AuthenticationForm): assert e.secs_to_freedom is not None secs_to_freedom = int(e.secs_to_freedom) error_message = _( - "You're making too many attempts to sign in. " - + "Try again in {} seconds or contact your organization administrator " - + "for help." + "You're making too many attempts to sign in." + " Try again in {} seconds or contact your organization administrator" + " for help." ) raise ValidationError(error_message.format(secs_to_freedom)) diff --git a/zerver/lib/management.py b/zerver/lib/management.py index 579fb177fe..57e191d7a9 100644 --- a/zerver/lib/management.py +++ b/zerver/lib/management.py @@ -163,9 +163,8 @@ server via `ps -ef` or reading bash history. Prefer return UserProfile.objects.select_related().get(delivery_email__iexact=email.strip()) except MultipleObjectsReturned: raise CommandError( - "This Zulip server contains multiple users with that email " - + "(in different realms); please pass `--realm` " - "to specify which one to modify." + "This Zulip server contains multiple users with that email (in different realms);" + " please pass `--realm` to specify which one to modify." ) except UserProfile.DoesNotExist: raise CommandError(f"This Zulip server does not contain a user with email '{email}'") diff --git a/zerver/lib/markdown/__init__.py b/zerver/lib/markdown/__init__.py index 7938ad8c7f..38bfe0503e 100644 --- a/zerver/lib/markdown/__init__.py +++ b/zerver/lib/markdown/__init__.py @@ -849,8 +849,8 @@ class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor): schema_re = r"(?:https?://)" host_re = r"(?:youtu\.be/|(?:\w+\.)?youtube(?:-nocookie)?\.com/)" param_re = ( - r"(?:(?:(?:v|embed)/)|" - + r"(?:(?:(?:watch|playlist)(?:_popup|_videos)?(?:\.php)?)?(?:\?|#!?)(?:.+&)?v(?:ideo_ids)?=))" + r"(?:(?:(?:v|embed)/)" + r"|(?:(?:(?:watch|playlist)(?:_popup|_videos)?(?:\.php)?)?(?:\?|#!?)(?:.+&)?v(?:ideo_ids)?=))" ) id_re = r"([0-9A-Za-z_-]+)" youtube_re = r"^({schema_re}?{host_re}{param_re}?)?{id_re}(?(1).+)?$" @@ -883,8 +883,8 @@ class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor): vimeo_re = ( r"^((http|https)?:\/\/(www\.)?vimeo.com\/" - + r"(?:channels\/(?:\w+\/)?|groups\/" - + r"([^\/]*)\/videos\/|)(\d+)(?:|\/\?))$" + r"(?:channels\/(?:\w+\/)?|groups\/" + r"([^\/]*)\/videos\/|)(\d+)(?:|\/\?))$" ) match = re.match(vimeo_re, url) if match is None: diff --git a/zerver/lib/markdown/api_return_values_table_generator.py b/zerver/lib/markdown/api_return_values_table_generator.py index bc09de8bcd..7a825106c3 100644 --- a/zerver/lib/markdown/api_return_values_table_generator.py +++ b/zerver/lib/markdown/api_return_values_table_generator.py @@ -194,7 +194,7 @@ class APIReturnValuesTablePreprocessor(Preprocessor): # Directly using `###` for subheading causes errors so use h3 with made up id. argument_template = ( '
[Zulip note: Sorry, we could not " - + "understand the formatting of your message]
" - ) + obj[ + "rendered_content" + ] = "[Zulip note: Sorry, we could not understand the formatting of your message]
" if rendered_content is not None: obj["is_me_message"] = Message.is_status_message(content, rendered_content) diff --git a/zerver/lib/onboarding.py b/zerver/lib/onboarding.py index acc8b31df5..2049759d64 100644 --- a/zerver/lib/onboarding.py +++ b/zerver/lib/onboarding.py @@ -74,7 +74,7 @@ def send_initial_pms(user: UserProfile) -> None: _( "If you are new to Zulip, check out our [Getting started guide]({getting_started_url})!" ), - "{organization_setup_text}" + "\n\n", + "{organization_setup_text}\n\n", "{demo_org_warning}", _( "I can also help you get set up! Just click anywhere on this message or press `r` to reply." diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.py index eaca443f08..e47deff92b 100644 --- a/zerver/lib/test_classes.py +++ b/zerver/lib/test_classes.py @@ -226,9 +226,9 @@ Output: else: # A web app request; use a browser User-Agent string. default_user_agent = ( - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " - + "AppleWebKit/537.36 (KHTML, like Gecko) " - + "Chrome/79.0.3945.130 Safari/537.36" + "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko)" + " Chrome/79.0.3945.130 Safari/537.36" ) if skip_user_agent: # Provide a way to disable setting User-Agent if desired. diff --git a/zerver/openapi/markdown_extension.py b/zerver/openapi/markdown_extension.py index 3cbdfb6ea1..a1d70b9530 100644 --- a/zerver/openapi/markdown_extension.py +++ b/zerver/openapi/markdown_extension.py @@ -307,16 +307,14 @@ def generate_curl_example( authentication_required = True else: raise AssertionError( - "Unhandled global securityScheme." - + " Please update the code to handle this scheme." + "Unhandled global securityScheme. Please update the code to handle this scheme." ) elif operation_security == []: if operation in insecure_operations: authentication_required = False else: raise AssertionError( - "Unknown operation without a securityScheme. " - + "Please update insecure_operations." + "Unknown operation without a securityScheme. Please update insecure_operations." ) else: raise AssertionError( diff --git a/zerver/openapi/openapi.py b/zerver/openapi/openapi.py index 072053239c..ca94bfd673 100644 --- a/zerver/openapi/openapi.py +++ b/zerver/openapi/openapi.py @@ -496,8 +496,8 @@ def validate_schema(schema: Dict[str, Any]) -> None: elif schema["type"] == "object": if "additionalProperties" not in schema: raise SchemaError( - "additionalProperties needs to be defined for objects to make " - + "sure they have no additional properties left to be documented." + "additionalProperties needs to be defined for objects to make sure they have no" + " additional properties left to be documented." ) for property_schema in schema.get("properties", {}).values(): validate_schema(property_schema) diff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.py index ef03d356e2..b22af6ebbb 100644 --- a/zerver/tests/test_auth_backends.py +++ b/zerver/tests/test_auth_backends.py @@ -2000,15 +2000,15 @@ class SAMLAuthBackendTest(SocialAuthBase): extra_attrs = "" for extra_attr_name, extra_attr_values in extra_attributes.items(): values = "".join( - 'See this avatar_103.jpeg.
' - + ' ' + "See this avatar_103.jpeg.
' + ' ' ) test_data = test_data.format(realm_id=zulip_realm.id) actual_output = convert(test_data) expected_output = ( - 'See this avatar_103.jpeg.
See this avatar_103.jpeg.
See ' - + ":cloud_with_lightning_and_rain:.
" + 'See :cloud_with_lightning_and_rain:.
' ) fragment = lxml.html.fromstring(test_data) fix_emojis(fragment, "http://example.com", "google") actual_output = lxml.html.tostring(fragment, encoding="unicode") expected_output = ( - 'See .
' + 'See .
' ) self.assertEqual(actual_output, expected_output) diff --git a/zerver/tests/test_link_embed.py b/zerver/tests/test_link_embed.py index 8c19e3d82f..4b707e9cce 100644 --- a/zerver/tests/test_link_embed.py +++ b/zerver/tests/test_link_embed.py @@ -589,9 +589,13 @@ class PreviewTestCase(ZulipTestCase): msg = Message.objects.select_related("sender").get(id=msg_id) with_preview = ( - '\n ' + '\n' + ' " ) self.assertEqual( with_preview, diff --git a/zerver/tests/test_markdown.py b/zerver/tests/test_markdown.py index 66b5981733..5903ea5e1c 100644 --- a/zerver/tests/test_markdown.py +++ b/zerver/tests/test_markdown.py @@ -2894,13 +2894,15 @@ class MarkdownTest(ZulipTestCase): def test_disabled_code_block_processor(self) -> None: msg = ( "Hello,\n\n" - + " I am writing this message to test something. I am writing this message to test something." + " I am writing this message to test something. I am writing this message to test" + " something." ) converted = markdown_convert_wrapper(msg) expected_output = ( "Hello,
\n" - + 'I am writing this message to test something. I am writing this message to test something.\n'
- + "
I am writing this message to test'
+ " something. I am writing this message to test something.\n"
+ "
Hello,
\n" - + "I am writing this message to test something. I am writing this message to test something.
" + "I am writing this message to test something. I am writing this message to test" + " something.
" ) self.assertEqual(rendering_result.rendered_content, expected_output) diff --git a/zerver/tests/test_message_fetch.py b/zerver/tests/test_message_fetch.py index c5bbc8aa64..b03c777e7e 100644 --- a/zerver/tests/test_message_fetch.py +++ b/zerver/tests/test_message_fetch.py @@ -2178,8 +2178,10 @@ class GetOldMessagesTest(ZulipTestCase): self.assertEqual(meeting_message[MATCH_TOPIC], "meetings") self.assertEqual( meeting_message["match_content"], - 'discuss lunch after ' - + 'lunch
', + ( + 'discuss lunch after lunch
' + ), ) (lunch_message,) = (m for m in messages if m[TOPIC_NAME] == "lunch plans") @@ -2224,7 +2226,7 @@ class GetOldMessagesTest(ZulipTestCase): self.assertEqual(japanese_message[MATCH_TOPIC], '日本') self.assertEqual( japanese_message["match_content"], - '昨日、日本' + " のお菓子を送りました。
", + '昨日、日本 のお菓子を送りました。
', ) (english_message,) = (m for m in messages if m[TOPIC_NAME] == "english") @@ -2372,7 +2374,7 @@ class GetOldMessagesTest(ZulipTestCase): self.assertEqual(japanese_message[MATCH_TOPIC], '日本語') self.assertEqual( japanese_message["match_content"], - '昨日、日本の' + "お菓子を送りました。
", + '昨日、日本のお菓子を送りました。
', ) english_message = [m for m in messages if m[TOPIC_NAME] == "english"][0] diff --git a/zerver/tests/test_middleware.py b/zerver/tests/test_middleware.py index 3440a514f1..3140ac8d62 100644 --- a/zerver/tests/test_middleware.py +++ b/zerver/tests/test_middleware.py @@ -123,8 +123,8 @@ class OpenGraphTest(ZulipTestCase): "Logging out | Zulip help center", # Ideally we'd do something better here [ - "Your feedback helps us make Zulip better for everyone! Please contact us " - + "with questions, suggestions, and feature requests." + "Your feedback helps us make Zulip better for everyone! Please contact us with" + " questions, suggestions, and feature requests." ], ["Click on the gear"], ) diff --git a/zerver/tests/test_new_users.py b/zerver/tests/test_new_users.py index a601d192a2..ed7f986848 100644 --- a/zerver/tests/test_new_users.py +++ b/zerver/tests/test_new_users.py @@ -132,14 +132,19 @@ class TestBrowserAndOsUserAgentStrings(ZulipTestCase): super().setUp() self.user_agents = [ ( - "mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) " - + "Chrome/54.0.2840.59 Safari/537.36", + ( + "mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)" + " Chrome/54.0.2840.59 Safari/537.36" + ), "Chrome", "Linux", ), ( - "mozilla/5.0 (windows nt 6.1; win64; x64) applewebkit/537.36 (khtml, like gecko) " - + "chrome/56.0.2924.87 safari/537.36", + ( + "mozilla/5.0 (windows nt 6.1; win64; x64) " + " applewebkit/537.36 (khtml, like gecko)" + " chrome/56.0.2924.87 safari/537.36" + ), "Chrome", "Windows", ), @@ -159,36 +164,46 @@ class TestBrowserAndOsUserAgentStrings(ZulipTestCase): "Android", ), ( - "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) " - "AppleWebKit/602.1.50 (KHTML, like Gecko) " - "CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1", + ( + "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X)" + " AppleWebKit/602.1.50 (KHTML, like Gecko)" + " CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1" + ), "Chrome", "iOS", ), ( - "Mozilla/5.0 (iPad; CPU OS 6_1_3 like Mac OS X) " - + "AppleWebKit/536.26 (KHTML, like Gecko) " - + "Version/6.0 Mobile/10B329 Safari/8536.25", + ( + "Mozilla/5.0 (iPad; CPU OS 6_1_3 like Mac OS X)" + " AppleWebKit/536.26 (KHTML, like Gecko)" + " Version/6.0 Mobile/10B329 Safari/8536.25" + ), "Safari", "iOS", ), ( - "Mozilla/5.0 (iPhone; CPU iPhone OS 6_1_4 like Mac OS X) " - + "AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10B350", + ( + "Mozilla/5.0 (iPhone; CPU iPhone OS 6_1_4 like Mac OS X)" + " AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10B350" + ), None, "iOS", ), ( - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) " - + "AppleWebKit/537.36 (KHTML, like Gecko) " - + "Chrome/56.0.2924.87 Safari/537.36", + ( + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6)" + " AppleWebKit/537.36 (KHTML, like Gecko)" + " Chrome/56.0.2924.87 Safari/537.36" + ), "Chrome", "macOS", ), ( - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) " - + "AppleWebKit/602.3.12 (KHTML, like Gecko) " - + "Version/10.0.2 Safari/602.3.12", + ( + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6)" + " AppleWebKit/602.3.12 (KHTML, like Gecko)" + " Version/10.0.2 Safari/602.3.12" + ), "Safari", "macOS", ), @@ -196,37 +211,46 @@ class TestBrowserAndOsUserAgentStrings(ZulipTestCase): ("ZulipMobile/1.0.12 (Android 7.1.1)", "Zulip", "Android"), ("ZulipMobile/0.7.1.1 (iOS 10.3.1)", "Zulip", "iOS"), ( - "ZulipElectron/1.1.0-beta Mozilla/5.0 (Windows NT 10.0; Win64; x64) " - + "AppleWebKit/537.36 (KHTML, like Gecko) Zulip/1.1.0-beta " - + "Chrome/56.0.2924.87 Electron/1.6.8 Safari/537.36", + ( + "ZulipElectron/1.1.0-beta Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko) Zulip/1.1.0-beta" + " Chrome/56.0.2924.87 Electron/1.6.8 Safari/537.36" + ), "Zulip", "Windows", ), ( - "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.7 (KHTML, " - "like Gecko) Ubuntu/11.10 Chromium/16.0.912.77 " - "Chrome/16.0.912.77 Safari/535.7", + ( + "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.7 (KHTML, like Gecko)" + " Ubuntu/11.10 Chromium/16.0.912.77 Chrome/16.0.912.77 Safari/535.7" + ), "Chromium", "Linux", ), ( - "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 " - "(KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36 " - "OPR/15.0.1147.100", + ( + "Mozilla/5.0 (Windows NT 6.1; WOW64)" + " AppleWebKit/537.36 (KHTML, like Gecko)" + " Chrome/28.0.1500.52 Safari/537.36 OPR/15.0.1147.100" + ), "Opera", "Windows", ), ( - "Mozilla/5.0 (Windows NT 10.0; <64-bit tags>) AppleWebKit/" - "