mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 18:36:36 +00:00
typing: Use TYPE_CHECKING when dealing with cyclic dependencies.
This commit is contained in:
@@ -13,6 +13,8 @@ exclude_lines =
|
|||||||
def __str__[(]self[)] -> .*:
|
def __str__[(]self[)] -> .*:
|
||||||
# Don't require coverage for errors about unsupported webhook event types
|
# Don't require coverage for errors about unsupported webhook event types
|
||||||
raise UnexpectedWebhookEventType
|
raise UnexpectedWebhookEventType
|
||||||
|
# Don't require coverage for blocks only run when type-checking
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
|
||||||
[run]
|
[run]
|
||||||
omit =
|
omit =
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ from django.db.models import Q
|
|||||||
from django.core.cache.backends.base import BaseCache
|
from django.core.cache.backends.base import BaseCache
|
||||||
from django.http import HttpRequest
|
from django.http import HttpRequest
|
||||||
|
|
||||||
from typing import Any, Callable, Dict, Iterable, List, Optional, TypeVar, Tuple
|
from typing import Any, Callable, Dict, Iterable, List, \
|
||||||
|
Optional, TypeVar, Tuple, TYPE_CHECKING
|
||||||
|
|
||||||
from zerver.lib.utils import statsd, statsd_key, make_safe_digest
|
from zerver.lib.utils import statsd, statsd_key, make_safe_digest
|
||||||
import time
|
import time
|
||||||
@@ -19,7 +20,7 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
if False:
|
if TYPE_CHECKING:
|
||||||
# These modules have to be imported for type annotations but
|
# These modules have to be imported for type annotations but
|
||||||
# they cannot be imported at runtime due to cyclic dependency.
|
# they cannot be imported at runtime due to cyclic dependency.
|
||||||
from zerver.models import UserProfile, Realm, Message
|
from zerver.models import UserProfile, Realm, Message
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from typing import (
|
from typing import (
|
||||||
Any, Callable, Dict, Generator, Iterable, Iterator, List, Mapping,
|
Any, Callable, Dict, Generator, Iterable, Iterator, List, Mapping,
|
||||||
Optional, Tuple, Union, IO, TypeVar
|
Optional, Tuple, Union, IO, TypeVar, TYPE_CHECKING
|
||||||
)
|
)
|
||||||
|
|
||||||
from django.core import signing
|
from django.core import signing
|
||||||
@@ -38,7 +38,7 @@ from zerver.models import (
|
|||||||
UserProfile,
|
UserProfile,
|
||||||
)
|
)
|
||||||
|
|
||||||
if False:
|
if TYPE_CHECKING:
|
||||||
# Avoid an import cycle; we only need these for type annotations.
|
# Avoid an import cycle; we only need these for type annotations.
|
||||||
from zerver.lib.test_classes import ZulipTestCase, MigrationsTestCase
|
from zerver.lib.test_classes import ZulipTestCase, MigrationsTestCase
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from typing import Dict, Optional
|
from typing import Dict, Optional, TYPE_CHECKING
|
||||||
|
|
||||||
if False:
|
if TYPE_CHECKING:
|
||||||
from zerver.tornado.event_queue import ClientDescriptor
|
from zerver.tornado.event_queue import ClientDescriptor
|
||||||
|
|
||||||
descriptors_by_handler_id = {} # type: Dict[int, ClientDescriptor]
|
descriptors_by_handler_id = {} # type: Dict[int, ClientDescriptor]
|
||||||
|
|||||||
Reference in New Issue
Block a user