Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
mypy: Enable truthy-bool errors.
Anders Kaseorgdf69e1d9792a
diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.pyindex 4a009f0833f..f302a62f11f 100644--- a/corporate/tests/test_stripe.py+++ b/corporate/tests/test_stripe.py@@ -4706,7 +4706,7 @@ class InvoiceTest(StripeTestCase):def test_invoice_plan_without_stripe_customer(self) -> None:self.local_upgrade(self.seat_count, True, CustomerPlan.ANNUAL, False, False)plan = get_current_plan_by_realm(get_realm("zulip"))- assert plan and plan.customer+ assert plan is not Noneplan.customer.stripe_customer_id = Noneplan.customer.save(update_fields=["stripe_customer_id"])with self.assertRaises(BillingError) as context:diff --git a/pyproject.toml b/pyproject.tomlindex 92b1b7e2757..df83fbf2260 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -27,6 +27,7 @@ warn_return_any = false# Enable optional errors.enable_error_code = ["redundant-expr",+ "truthy-bool",]# Display the codes needed for # type: ignore[code] annotations.diff --git a/zerver/actions/message_send.py b/zerver/actions/message_send.pyindex 17dccbd51bd..19cd1443ce3 100644--- a/zerver/actions/message_send.py+++ b/zerver/actions/message_send.py@@ -1396,7 +1396,7 @@ def check_message(elif addressee.is_private():user_profiles = addressee.user_profiles()- mirror_message = client and client.name in [+ mirror_message = client.name in ["zephyr_mirror","irc_mirror","jabber_mirror",diff --git a/zerver/tests/test_custom_profile_data.py b/zerver/tests/test_custom_profile_data.pyindex ac701cbb4af..6932a0bc6bd 100644--- a/zerver/tests/test_custom_profile_data.py+++ b/zerver/tests/test_custom_profile_data.py@@ -754,7 +754,6 @@ class ListCustomProfileFieldTest(CustomProfileFieldTestCase):iago = self.example_user("iago")test_bot = self.create_test_bot("foo-bot", iago)self.login_user(iago)- assert test_botwith queries_captured() as queries:response = self.client_get(diff --git a/zerver/tests/test_import_export.py b/zerver/tests/test_import_export.pyindex d4e13a09c66..529de861819 100644--- a/zerver/tests/test_import_export.py+++ b/zerver/tests/test_import_export.py@@ -644,7 +644,6 @@ class RealmImportExportTest(ExportFile):realm_emoji = check_add_realm_emoji(realm=hamlet.realm, name="hawaii", author=hamlet, image_file=img_file)- assert realm_emojiself.assertEqual(realm_emoji.name, "hawaii")# Deactivate a user to ensure such a case is covered.@@ -801,7 +800,7 @@ class RealmImportExportTest(ExportFile):imported_realm_result = f(imported_realm)# orig_realm_result should be truthy and have some values, otherwise# the test is kind of meaningless- assert orig_realm_result+ assert orig_realm_result # type: ignore[truthy-bool] # see above# It may be helpful to do print(f.__name__) if you are having# trouble debugging this.diff --git a/zerver/tests/test_transfer.py b/zerver/tests/test_transfer.pyindex 116409fe5d8..3188f772554 100644--- a/zerver/tests/test_transfer.py+++ b/zerver/tests/test_transfer.py@@ -88,8 +88,6 @@ class TransferUploadsToS3Test(ZulipTestCase):with get_test_image_file("img.png") as image_file:emoji = check_add_realm_emoji(othello.realm, emoji_name, othello, image_file)- if not emoji:- raise AssertionError("Unable to add emoji.")emoji_path = RealmEmoji.PATH_ID_TEMPLATE.format(realm_id=othello.realm_id,@@ -115,8 +113,6 @@ class TransferUploadsToS3Test(ZulipTestCase):with get_test_image_file("animated_img.gif") as image_file:emoji = check_add_realm_emoji(othello.realm, emoji_name, othello, image_file)- if not emoji:- raise AssertionError("Unable to add emoji.")emoji_path = RealmEmoji.PATH_ID_TEMPLATE.format(realm_id=othello.realm_id,diff --git a/zerver/webhooks/jira/view.py b/zerver/webhooks/jira/view.pyindex 442936227d4..ac2e23693ab 100644--- a/zerver/webhooks/jira/view.py+++ b/zerver/webhooks/jira/view.py@@ -78,17 +78,16 @@ def convert_jira_markup(content: str, realm: Realm) -> str:# Try to convert a Jira user mention of format [~username] into a# Zulip user mention. We don't know the email, just the Jira username,# so we naively guess at their Zulip account using this- if realm:- mention_re = re.compile("\\[~(.*?)\\]")- for username in mention_re.findall(content):- # Try to look up username- user_profile = guess_zulip_user_from_jira(username, realm)- if user_profile:- replacement = f"**{user_profile.full_name}**"- else:- replacement = f"**{username}**"-- content = content.replace(f"[~{username}]", replacement)+ mention_re = re.compile("\\[~(.*?)\\]")+ for username in mention_re.findall(content):+ # Try to look up username+ user_profile = guess_zulip_user_from_jira(username, realm)+ if user_profile:+ replacement = f"**{user_profile.full_name}**"+ else:+ replacement = f"**{username}**"++ content = content.replace(f"[~{username}]", replacement)return content