Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
mypy: Enable redundant-expr errors.
Anders Kaseorgc944adfcc682
diff --git a/pyproject.toml b/pyproject.tomlindex e3b92d0dc16..92b1b7e2757 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -24,6 +24,11 @@ disallow_untyped_calls = falsedisallow_untyped_decorators = falsewarn_return_any = false+# Enable optional errors.+enable_error_code = [+ "redundant-expr",+]+# Display the codes needed for # type: ignore[code] annotations.show_error_codes = truediff --git a/tools/lib/capitalization.py b/tools/lib/capitalization.pyindex 2510b5b2ec0..4eee7407e98 100644--- a/tools/lib/capitalization.py+++ b/tools/lib/capitalization.py@@ -218,7 +218,7 @@ def check_capitalization(strings: List[str]) -> Tuple[List[str], List[str], Listcapitalized = is_capitalized(safe_text)if not capitalized:errors.append(text)- elif capitalized and has_ignored_phrase:+ elif has_ignored_phrase:ignored.append(text)banned_word_errors.extend(check_banned_words(text))diff --git a/tools/lib/template_parser.py b/tools/lib/template_parser.pyindex a015e445fb0..76655aa33bd 100644--- a/tools/lib/template_parser.py+++ b/tools/lib/template_parser.py@@ -464,7 +464,7 @@ def validate(fn: Optional[str] = None, text: Optional[str] = None) -> List[Tokenf"Tag must be self-closing: {tag} at {fn} line {token.line}, col {token.col}")elif kind == "html_singleton":- if not state.foreign and tag not in HTML_VOID_TAGS:+ if tag not in HTML_VOID_TAGS:raise TemplateParserException(f"Tag must not be self-closing: {tag} at {fn} line {token.line}, col {token.col}")diff --git a/zerver/lib/mention.py b/zerver/lib/mention.pyindex 232946aa618..7a1bd3d1a16 100644--- a/zerver/lib/mention.py+++ b/zerver/lib/mention.py@@ -87,8 +87,7 @@ class MentionBackend:# We expect callers who take advantage of our cache to supply both# id and full_name in the user mentions in their messages.for user in user_list:- if user.id is not None and user.full_name is not None:- self.user_cache[(user.id, user.full_name)] = user+ self.user_cache[(user.id, user.full_name)] = userresult += user_listdiff --git a/zerver/lib/scim.py b/zerver/lib/scim.pyindex a3670b4f197..b21125565ec 100644--- a/zerver/lib/scim.py+++ b/zerver/lib/scim.py@@ -181,7 +181,7 @@ class ZulipSCIMUser(SCIMUser):self._full_name_new_value = new_valuedef change_is_active(self, new_value: bool) -> None:- if new_value is not None and new_value != self.obj.is_active:+ if new_value != self.obj.is_active:self._is_active_new_value = new_valuedef handle_replace(diff --git a/zerver/lib/webhooks/common.py b/zerver/lib/webhooks/common.pyindex fe89839166d..4e736c7a87d 100644--- a/zerver/lib/webhooks/common.py+++ b/zerver/lib/webhooks/common.py@@ -114,7 +114,7 @@ def check_send_webhook_message(# double escape their URLs in a manner that escaped space characters# (%20) are never properly decoded. We work around that by making sure# that the URL parameters are decoded on our end.- if stream is not None and unquote_url_parameters:+ if unquote_url_parameters:stream = unquote(stream)if user_specified_topic is not None: