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 = ( '

' - + " {event_type} {op}

\n{description}\n\n\n" + "{event_type} {op}

\n{description}\n\n\n" ) for events in events_dict["oneOf"]: event_type: Dict[str, Any] = events["properties"]["type"] diff --git a/zerver/lib/message.py b/zerver/lib/message.py index 764c032b16..a56135d4c3 100644 --- a/zerver/lib/message.py +++ b/zerver/lib/message.py @@ -570,10 +570,9 @@ class MessageDict: if rendered_content is not None: obj["rendered_content"] = rendered_content else: - obj["rendered_content"] = ( - "

[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( - '' - + f"{value}" + '' + f"{value}" for value in extra_attr_values ) extra_attrs += ( - f'' - + f"{values}" + f'' + f"{values}" ) unencoded_saml_response = self.fixture_data("samlresponse.txt", type="saml").format( @@ -2815,8 +2815,11 @@ class SAMLAuthBackendTest(SocialAuthBase): m.output, [ self.logger_output( - "AuthFailed: Authentication failed: SAML user from IdP test_idp rejected due to " - + "missing entitlement for subdomain ''. User entitlements: ['zephyr'].", + ( + "AuthFailed: Authentication failed: SAML user from IdP test_idp" + " rejected due to missing entitlement for subdomain ''. User" + " entitlements: ['zephyr']." + ), "info", ) ], @@ -2839,8 +2842,11 @@ class SAMLAuthBackendTest(SocialAuthBase): m.output, [ self.logger_output( - "AuthFailed: Authentication failed: SAML user from IdP test_idp rejected due to " - + "missing entitlement for subdomain 'zulip'. User entitlements: ['zephyr', 'othersubdomain'].", + ( + "AuthFailed: Authentication failed: SAML user from IdP test_idp rejected" + " due to missing entitlement for subdomain 'zulip'. User entitlements:" + " ['zephyr', 'othersubdomain']." + ), "info", ) ], @@ -2934,8 +2940,10 @@ class SAMLAuthBackendTest(SocialAuthBase): m.output, [ self.logger_output( - "Exception while syncing custom profile fields for " - + f"user {self.user_profile.id}: Custom profile field with name title not found.", + ( + "Exception while syncing custom profile fields for user" + f" {self.user_profile.id}: Custom profile field with name title not found." + ), "warning", ) ], diff --git a/zerver/tests/test_bots.py b/zerver/tests/test_bots.py index a06b0b79b0..88fcffcd96 100644 --- a/zerver/tests/test_bots.py +++ b/zerver/tests/test_bots.py @@ -118,7 +118,7 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): error_message = ( "Can't create bots until FAKE_EMAIL_DOMAIN is correctly configured.\n" - + "Please contact your server administrator." + "Please contact your server administrator." ) self.assert_json_error(result, error_message) self.assert_num_bots_equal(0) diff --git a/zerver/tests/test_email_notifications.py b/zerver/tests/test_email_notifications.py index 3b043bd4c1..9ea8bb645d 100644 --- a/zerver/tests/test_email_notifications.py +++ b/zerver/tests/test_email_notifications.py @@ -1451,7 +1451,7 @@ class TestMissedMessages(ZulipTestCase): actual_output = convert(test_data) expected_output = ( '
' - + "/user_uploads/{realm_id}/1f/some_random_value
" + "/user_uploads/{realm_id}/1f/some_random_value" ) expected_output = expected_output.format(realm_id=zephyr_realm.id) self.assertEqual(actual_output, expected_output) @@ -1465,27 +1465,31 @@ class TestMissedMessages(ZulipTestCase): # A narrow URL which begins with a '#'. test_data = ( '

Conversation

' + ' title="#narrow/stream/test/topic/test.20topic/near/142">Conversation

' ) actual_output = convert(test_data) expected_output = ( - '

Conversation

' + '

Conversation

' ) self.assertEqual(actual_output, expected_output) # Scrub inline images. test_data = ( - '

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.

' ) expected_output = expected_output.format(realm_id=zulip_realm.id) self.assertEqual(actual_output, expected_output) @@ -1493,16 +1497,17 @@ class TestMissedMessages(ZulipTestCase): # A message containing only an inline image URL preview, we do # somewhat more extensive surgery. test_data = ( - '
' - + '
' + '
' + '
' ) actual_output = convert(test_data) expected_output = ( - '

' - + "https://www.google.com/images/srpr/logo4w.png

" + '

' + "https://www.google.com/images/srpr/logo4w.png

" ) self.assertEqual(actual_output, expected_output) @@ -1548,15 +1553,17 @@ class TestMissedMessages(ZulipTestCase): def test_fix_emoji(self) -> None: # An emoji. test_data = ( - '

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 :cloud_with_lightning_and_rain:.

' + '

See :cloud_with_lightning_and_rain:.

' ) 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 = ( - '

http://test.org/

\n
Description text
' + '

http://test.org/

\n' + '
Description' + " text
" ) 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"
+            "
" ) self.assertEqual(converted, expected_output) @@ -2911,7 +2913,8 @@ class MarkdownTest(ZulipTestCase): rendering_result = markdown_convert(msg, message_realm=realm, email_gateway=True) expected_output = ( "

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/" - " (KHTML, like Gecko) Chrome/ Safari" - "/ Edge/." - "", + ( + "Mozilla/5.0 (Windows NT 10.0; <64-bit tags>)" + " AppleWebKit/ (KHTML, like Gecko)" + " Chrome/ Safari/" + " Edge/." + ), "Edge", "Windows", ), ( - "Mozilla/5.0 (X11; CrOS x86_64 10895.56.0) AppleWebKit/537.36 " - "(KHTML, like Gecko) Chrome/69.0.3497.95 Safari/537.36", + ( + "Mozilla/5.0 (X11; CrOS x86_64 10895.56.0) AppleWebKit/537.36" + " (KHTML, like Gecko) Chrome/69.0.3497.95 Safari/537.36" + ), "Chrome", "ChromeOS", ), diff --git a/zerver/tests/test_retention.py b/zerver/tests/test_retention.py index f1b7f61033..e759be7098 100644 --- a/zerver/tests/test_retention.py +++ b/zerver/tests/test_retention.py @@ -189,9 +189,10 @@ class ArchiveMessagesTestingBase(RetentionTestingBase): self.subscribe(user_profile, "Denmark") body = ( - "Some files here ... [zulip.txt](http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/zulip.txt)" - + " http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/temp_file.py.... Some more...." - + " http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/abc.py" + "Some files here ..." + " [zulip.txt](http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/zulip.txt)" + " http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/temp_file.py.... Some" + " more.... http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/abc.py" ).format(id=realm_id, host=host) expired_message_id = self.send_stream_message(user_profile, "Denmark", body) diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py index 3bd0e44da1..54e276f397 100644 --- a/zerver/tests/test_signup.py +++ b/zerver/tests/test_signup.py @@ -1348,9 +1348,10 @@ class InviteUserTest(InviteUserBase): result = self.invite(invitee_emails, ["Denmark"]) self.assert_json_error( result, - "Some of those addresses are already using Zulip," - + " so we didn't send them an invitation." - + " We did send invitations to everyone else!", + ( + "Some of those addresses are already using Zulip, so we didn't send them an" + " invitation. We did send invitations to everyone else!" + ), ) def test_invite_mirror_dummy_user(self) -> None: diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py index 26a89b38e8..00b99c5544 100644 --- a/zerver/tests/test_subs.py +++ b/zerver/tests/test_subs.py @@ -2082,7 +2082,7 @@ class StreamAdminTest(ZulipTestCase): # Simulate that a stream by the same name has already been # deactivated, just to exercise our renaming logic: # Since we do not know the id of these simulated stream we prepend the name with a random hashed_stream_id - ensure_stream(realm, "DB32B77" + "!DEACTIVATED:" + active_name, acting_user=None) + ensure_stream(realm, "DB32B77!DEACTIVATED:" + active_name, acting_user=None) events: List[Mapping[str, Any]] = [] with self.tornado_redirected_to_list(events, expected_num_events=1): diff --git a/zerver/webhooks/basecamp/view.py b/zerver/webhooks/basecamp/view.py index 4626a25e60..7c0845977f 100644 --- a/zerver/webhooks/basecamp/view.py +++ b/zerver/webhooks/basecamp/view.py @@ -16,8 +16,8 @@ from .support_event import SUPPORT_EVENTS DOCUMENT_TEMPLATE = "{user_name} {verb} the document [{title}]({url})" QUESTION_TEMPLATE = "{user_name} {verb} the question [{title}]({url})" QUESTIONS_ANSWER_TEMPLATE = ( - "{user_name} {verb} the [answer]({answer_url}) " - + "of the question [{question_title}]({question_url})" + "{user_name} {verb} the [answer]({answer_url})" + " of the question [{question_title}]({question_url})" ) COMMENT_TEMPLATE = ( "{user_name} {verb} the [comment]({answer_url}) of the task [{task_title}]({task_url})" diff --git a/zerver/webhooks/stripe/tests.py b/zerver/webhooks/stripe/tests.py index 10c0c2dded..3be4d39038 100644 --- a/zerver/webhooks/stripe/tests.py +++ b/zerver/webhooks/stripe/tests.py @@ -158,7 +158,7 @@ Billing method: send invoice""" expected_topic = "cus_00000000000000" expected_message = ( "[Customer](https://dashboard.stripe.com/customers/cus_00000000000000) updated" - + "\n* Account balance is now 100" + "\n* Account balance is now 100" ) self.check_webhook( "customer_updated__account_balance", diff --git a/zerver/webhooks/taiga/tests.py b/zerver/webhooks/taiga/tests.py index 79cb33c1fa..265cef910e 100644 --- a/zerver/webhooks/taiga/tests.py +++ b/zerver/webhooks/taiga/tests.py @@ -81,8 +81,9 @@ class TaigaHookTests(WebhookTestCase): def test_taiga_userstory_changed_due_date(self) -> None: message = ( - "[Aditya Verma](https://tree.taiga.io/profile/orientor) changed due date of user story " - + "[Nice Issue](https://tree.taiga.io/project/orientor-sd/us/54) from 2020-02-15 to 2020-02-22." + "[Aditya Verma](https://tree.taiga.io/profile/orientor) changed due date of user story" + " [Nice Issue](https://tree.taiga.io/project/orientor-sd/us/54) from 2020-02-15 to" + " 2020-02-22." ) self.check_webhook("userstory_changed_due_date", self.TOPIC, message) @@ -145,7 +146,8 @@ class TaigaHookTests(WebhookTestCase): def test_taiga_task_changed_due_date(self) -> None: message = ( "[Aditya Verma](https://tree.taiga.io/profile/orientor) changed due date of task" - + " [nice task](https://tree.taiga.io/project/orientor-sd/task/56) from 2020-02-22 to 2020-02-15." + " [nice task](https://tree.taiga.io/project/orientor-sd/task/56) from 2020-02-22 to" + " 2020-02-15." ) self.check_webhook("task_changed_due_date", self.TOPIC, message) @@ -235,8 +237,9 @@ class TaigaHookTests(WebhookTestCase): def test_taiga_issue_changed_due_date(self) -> None: message = ( - "[Aditya Verma](https://tree.taiga.io/profile/orientor) changed due date of issue [Issues](https://tree.taiga.io/project/orientor-sd/issue/49) " - + "from 2020-03-08 to 2020-02-22." + "[Aditya Verma](https://tree.taiga.io/profile/orientor) changed due date of issue" + " [Issues](https://tree.taiga.io/project/orientor-sd/issue/49) from 2020-03-08 to" + " 2020-02-22." ) self.check_webhook("issue_changed_due_date", self.TOPIC, message) @@ -302,8 +305,9 @@ class TaigaHookTests(WebhookTestCase): def test_taiga_relateduserstory_created_link(self) -> None: message = ( - "[Aditya Verma](https://tree.taiga.io/profile/orientor) added a related user story [Nice Issue](https://tree.taiga.io/project/orientor-sd/us/54) " - + "to the epic [ASAS](https://tree.taiga.io/project/orientor-sd/epic/42)." + "[Aditya Verma](https://tree.taiga.io/profile/orientor) added a related user story" + " [Nice Issue](https://tree.taiga.io/project/orientor-sd/us/54) to the epic" + " [ASAS](https://tree.taiga.io/project/orientor-sd/epic/42)." ) self.check_webhook("relateduserstory_created_link", self.TOPIC, message) diff --git a/zerver/webhooks/taiga/view.py b/zerver/webhooks/taiga/view.py index 6977059503..168779b73a 100644 --- a/zerver/webhooks/taiga/view.py +++ b/zerver/webhooks/taiga/view.py @@ -59,12 +59,12 @@ templates = { }, "relateduserstory": { "create": ( - "[{user}]({user_link}) added a related user story " - "{userstory_subject} to the epic {epic_subject}." + "[{user}]({user_link}) added a related user story" + " {userstory_subject} to the epic {epic_subject}." ), "delete": ( - "[{user}]({user_link}) removed a related user story " - + "{userstory_subject} from the epic {epic_subject}." + "[{user}]({user_link}) removed a related user story" + " {userstory_subject} from the epic {epic_subject}." ), }, "userstory": { diff --git a/zerver/webhooks/trello/view/card_actions.py b/zerver/webhooks/trello/view/card_actions.py index 444951abe0..08d9acc881 100644 --- a/zerver/webhooks/trello/view/card_actions.py +++ b/zerver/webhooks/trello/view/card_actions.py @@ -52,7 +52,7 @@ ACTIONS_TO_MESSAGE_MAPPER = { SET_DESC: "set description for {card_url_template} to:\n~~~ quote\n{desc}\n~~~\n", CHANGE_DESC: ( "changed description for {card_url_template} from\n" - + "~~~ quote\n{old_desc}\n~~~\nto\n~~~ quote\n{desc}\n~~~\n" + "~~~ quote\n{old_desc}\n~~~\nto\n~~~ quote\n{desc}\n~~~\n" ), REMOVE_DESC: "removed description from {card_url_template}.", ARCHIVE: "archived {card_url_template}.", diff --git a/zproject/backends.py b/zproject/backends.py index 4b57b26e1b..b19f9e92e8 100644 --- a/zproject/backends.py +++ b/zproject/backends.py @@ -2299,9 +2299,9 @@ class SAMLAuthBackend(SocialAuthMixin, SAMLAuth): ] if idps_without_limit_to_subdomains: self.logger.error( - "SAML_REQUIRE_LIMIT_TO_SUBDOMAINS is enabled and the following " - + "IdPs don't have limit_to_subdomains specified and will be ignored: " - + f"{idps_without_limit_to_subdomains}" + "SAML_REQUIRE_LIMIT_TO_SUBDOMAINS is enabled and the following IdPs don't have" + " limit_to_subdomains specified and will be ignored:" + f" {idps_without_limit_to_subdomains}" ) for idp_name in idps_without_limit_to_subdomains: del settings.SOCIAL_AUTH_SAML_ENABLED_IDPS[idp_name] @@ -2437,8 +2437,8 @@ class SAMLAuthBackend(SocialAuthMixin, SAMLAuth): return error_msg = ( - f"SAML user from IdP {idp.name} rejected due to missing entitlement " - + f"for subdomain '{subdomain}'. User entitlements: {entitlements}." + f"SAML user from IdP {idp.name} rejected due to missing entitlement for subdomain" + f" '{subdomain}'. User entitlements: {entitlements}." ) raise AuthFailed(self, error_msg) @@ -2545,7 +2545,7 @@ class SAMLAuthBackend(SocialAuthMixin, SAMLAuth): subdomain = self.choose_subdomain(relayed_params) if subdomain is None: error_msg = ( - "/complete/saml/: Can't figure out subdomain for this %s. " + "relayed_params: %s" + "/complete/saml/: Can't figure out subdomain for this %s. relayed_params: %s" ) self.logger.info(error_msg, saml_document.document_type(), relayed_params) return None @@ -2560,8 +2560,8 @@ class SAMLAuthBackend(SocialAuthMixin, SAMLAuth): idp_valid = self.validate_idp_for_subdomain(idp_name, subdomain) if not idp_valid: error_msg = ( - "/complete/saml/: Authentication request with IdP %s but this provider is not " - + "enabled for this subdomain %s." + "/complete/saml/: Authentication request with IdP %s but this provider is not" + " enabled for this subdomain %s." ) self.logger.info(error_msg, idp_name, subdomain) return None