archive: Fix typing for prev_sender variable.

We know that via the `AbstractMessage` class that `sender`
is of the type `UserProfile`.  We type this as `Optional`
to tell mypy that the operands to the right of the first
`or` can indeed be evaluated within the following `for` loop.
This commit is contained in:
Wyatt Hoodes 2019-07-28 10:55:33 -10:00 committed by Tim Abbott
parent 99bd55917e
commit f22b2c7e9d
1 changed files with 3 additions and 3 deletions

View File

@ -1,11 +1,11 @@
from typing import List
from typing import List, Optional
from django.http import HttpRequest, HttpResponse
from django.shortcuts import render
from django.template import loader
from zerver.lib.streams import get_stream_by_id
from zerver.models import Message, get_stream_recipient
from zerver.models import Message, get_stream_recipient, UserProfile
from zerver.lib.avatar import get_gravatar_url
from zerver.lib.response import json_success
from zerver.lib.timestamp import datetime_to_timestamp
@ -52,7 +52,7 @@ def archive(request: HttpRequest,
return get_response([], True, stream.name)
rendered_message_list = []
prev_sender = None
prev_sender = None # type: Optional[UserProfile]
for msg in all_messages:
include_sender = False
status_message = Message.is_status_message(msg.content, msg.rendered_content)