From f22b2c7e9db585bab47db41a24643c7bf9c85aae Mon Sep 17 00:00:00 2001 From: Wyatt Hoodes Date: Sun, 28 Jul 2019 10:55:33 -1000 Subject: [PATCH] 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. --- zerver/views/archive.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zerver/views/archive.py b/zerver/views/archive.py index 4516afc1c2..89d7fc0039 100644 --- a/zerver/views/archive.py +++ b/zerver/views/archive.py @@ -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)