mypy: Reorder and annotate variables around if statements.

This commit is contained in:
neiljp (Neil Pilgrim) 2017-08-03 22:53:19 -07:00 committed by Greg Price
parent 2d3b95a088
commit 52ed997d23
2 changed files with 9 additions and 10 deletions

View File

@ -56,19 +56,19 @@ def zulip_default_context(request):
"""
realm = get_realm_from_request(request)
if realm is not None:
if realm is None:
realm_uri = settings.SERVER_URI
realm_name = None
realm_icon = None
realm_description = None
realm_invite_required = False
else:
realm_uri = realm.uri
realm_name = realm.name
realm_icon = get_realm_icon_url(realm)
realm_description_raw = realm.description or "The coolest place in the universe."
realm_description = convert(realm_description_raw, message_realm=realm)
realm_invite_required = realm.invite_required
else:
realm_uri = settings.SERVER_URI
realm_name = None
realm_icon = None
realm_description = None
realm_invite_required = False
register_link_disabled = settings.REGISTER_LINK_DISABLED
login_link_disabled = settings.LOGIN_LINK_DISABLED

View File

@ -428,13 +428,12 @@ def get_realm_emoji_uncached(realm):
d = {}
from zerver.lib.emoji import get_emoji_url
for row in RealmEmoji.objects.filter(realm=realm).select_related('author'):
author = None
if row.author:
author = {
'id': row.author.id,
'email': row.author.email,
'full_name': row.author.full_name}
else:
author = None
d[row.name] = dict(source_url=get_emoji_url(row.file_name, row.realm_id),
deactivated=row.deactivated,
author=author)
@ -1696,7 +1695,7 @@ class UserPresence(models.Model):
def status_from_string(status):
# type: (NonBinaryStr) -> Optional[int]
if status == 'active':
status_val = UserPresence.ACTIVE
status_val = UserPresence.ACTIVE # type: Optional[int] # See https://github.com/python/mypy/issues/2611
elif status == 'idle':
status_val = UserPresence.IDLE
else: