|
7 | 7 | from functools import lru_cache |
8 | 8 | from itertools import cycle |
9 | 9 | from typing import ( |
| 10 | + TYPE_CHECKING, |
10 | 11 | Iterator, |
11 | 12 | Literal, |
12 | 13 | NotRequired, |
|
17 | 18 |
|
18 | 19 | from django.conf import settings |
19 | 20 | from django.contrib.auth import get_user_model |
20 | | -from django.contrib.auth.models import AbstractBaseUser |
21 | 21 | from django.db import connections |
22 | | -from django.db.models import Manager, Model |
23 | 22 | from django.db.utils import OperationalError |
24 | 23 |
|
25 | 24 | from common.core import ReplicaReadStrategy |
26 | 25 |
|
| 26 | +if TYPE_CHECKING: |
| 27 | + from django.contrib.auth.models import AbstractBaseUser |
| 28 | + from django.db.models.base import Model |
| 29 | + from django.db.models.manager import Manager |
| 30 | + |
| 31 | + |
27 | 32 | logger = logging.getLogger(__name__) |
28 | 33 |
|
29 | 34 | UNKNOWN = "unknown" |
30 | 35 | VERSIONS_INFO_FILE_LOCATION = ".versions.json" |
31 | 36 |
|
32 | | -ManagerType = TypeVar("ManagerType", bound=Manager[Model]) |
| 37 | +ManagerType = TypeVar("ManagerType", bound="Manager[Model]") |
33 | 38 |
|
34 | 39 | ReplicaNamePrefix = Literal["replica_", "cross_region_replica_"] |
35 | 40 | _replica_sequential_names_by_prefix: dict[ReplicaNamePrefix, Iterator[str]] = {} |
@@ -102,7 +107,7 @@ def get_version_info() -> VersionInfo: |
102 | 107 | version_json["image_tag"] = manifest_versions["."] |
103 | 108 |
|
104 | 109 | if not _is_saas: |
105 | | - user_objects: Manager[AbstractBaseUser] = getattr(get_user_model(), "objects") |
| 110 | + user_objects: "Manager[AbstractBaseUser]" = getattr(get_user_model(), "objects") |
106 | 111 |
|
107 | 112 | version_json["self_hosted_data"] = { |
108 | 113 | "has_users": user_objects.exists(), |
|
0 commit comments