mirror of https://github.com/zulip/zulip.git
message_send: Avoid unchecked cast.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
f6c73ed45a
commit
48719cb8c4
|
@ -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"
|
||||||
|
|
|
@ -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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue