message_send: Avoid unchecked cast.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-06-22 15:51:34 -07:00 committed by Tim Abbott
parent f6c73ed45a
commit 48719cb8c4
2 changed files with 4 additions and 15 deletions

View File

@ -8,17 +8,6 @@ rules:
languages: [python] languages: [python]
severity: ERROR 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-filter - id: dont-use-stream-objects-filter
pattern: Stream.objects.filter(...) pattern: Stream.objects.filter(...)
message: "Please use access_stream_by_*() to fetch Stream objects" message: "Please use access_stream_by_*() to fetch Stream objects"

View File

@ -195,10 +195,10 @@ def send_message_backend(request: HttpRequest, user_profile: UserProfile,
# Also, mypy can't detect that a single-item # Also, mypy can't detect that a single-item
# list populated from a Union[int, str] is actually # list populated from a Union[int, str] is actually
# a Union[Sequence[int], Sequence[str]]. # a Union[Sequence[int], Sequence[str]].
message_to = cast( if isinstance(stream_indicator, int):
Union[Sequence[int], Sequence[str]], message_to = [stream_indicator]
[stream_indicator], else:
) message_to = [stream_indicator]
else: else:
message_to = extract_private_recipients(req_to) message_to = extract_private_recipients(req_to)