From a0da4f6d30750a4f778620d3be582b1e011938f7 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Mon, 17 Dec 2018 11:14:47 -0800 Subject: [PATCH] python: Clean up various if False blocks. Most of these are now-unnecessary typing imports; some are just improved comments for those with other mypy motivations. --- zerver/lib/avatar.py | 3 --- zerver/lib/bot_lib.py | 3 +-- zerver/lib/cache.py | 2 +- zerver/lib/test_helpers.py | 1 + 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/zerver/lib/avatar.py b/zerver/lib/avatar.py index ecefa54207..943a44e8b9 100644 --- a/zerver/lib/avatar.py +++ b/zerver/lib/avatar.py @@ -1,8 +1,5 @@ from django.conf import settings -if False: - from zerver.models import UserProfile - from typing import Any, Dict, Optional from zerver.lib.avatar_hash import gravatar_hash, user_avatar_path_from_ids diff --git a/zerver/lib/bot_lib.py b/zerver/lib/bot_lib.py index e14ed859a1..fc923e4ab2 100644 --- a/zerver/lib/bot_lib.py +++ b/zerver/lib/bot_lib.py @@ -17,8 +17,7 @@ from zerver.lib.topic import get_topic_from_message_info import configparser -if False: - from mypy_extensions import NoReturn +from mypy_extensions import NoReturn from typing import Any, Optional, List, Dict from types import ModuleType diff --git a/zerver/lib/cache.py b/zerver/lib/cache.py index c8d8f215b9..f40d895748 100644 --- a/zerver/lib/cache.py +++ b/zerver/lib/cache.py @@ -19,9 +19,9 @@ import os import hashlib if False: - from zerver.models import UserProfile, Realm, Message # These modules have to be imported for type annotations but # they cannot be imported at runtime due to cyclic dependency. + from zerver.models import UserProfile, Realm, Message ReturnT = TypeVar('ReturnT') # Useful for matching return types via Callable[..., ReturnT] diff --git a/zerver/lib/test_helpers.py b/zerver/lib/test_helpers.py index f2e8cb2af4..0dcf30f4d9 100644 --- a/zerver/lib/test_helpers.py +++ b/zerver/lib/test_helpers.py @@ -51,6 +51,7 @@ from zerver.models import ( from zerver.lib.request import JsonableError if False: + # Avoid an import cycle; we only need these for type annotations. from zerver.lib.test_classes import ZulipTestCase, MigrationsTestCase import collections