Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
message_send: Avoid unchecked cast.
Anders Kaseorg48719cb8c426
diff --git a/tools/semgrep.yml b/tools/semgrep.ymlindex c1cf4b8e6b5..d5925629d95 100644--- a/tools/semgrep.yml+++ b/tools/semgrep.yml@@ -8,17 +8,6 @@ rules:languages: [python]severity: ERROR- - id: useless-if-body- patterns:- - pattern: |- if $X:- $S- else:- $S- message: "Useless if statment; both blocks have the same body"- languages: [python]- severity: ERROR-- id: dont-use-stream-objects-filterpattern: Stream.objects.filter(...)message: "Please use access_stream_by_*() to fetch Stream objects"diff --git a/zerver/views/message_send.py b/zerver/views/message_send.pyindex 0d992227050..065c459bf12 100644--- a/zerver/views/message_send.py+++ b/zerver/views/message_send.py@@ -195,10 +195,10 @@ def send_message_backend(request: HttpRequest, user_profile: UserProfile,# Also, mypy can't detect that a single-item# list populated from a Union[int, str] is actually# a Union[Sequence[int], Sequence[str]].- message_to = cast(- Union[Sequence[int], Sequence[str]],- [stream_indicator],- )+ if isinstance(stream_indicator, int):+ message_to = [stream_indicator]+ else:+ message_to = [stream_indicator]else:message_to = extract_private_recipients(req_to)