Skip to content

Commit

Permalink
ref: get proper base manager typing
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile-sentry committed Jun 6, 2024
1 parent 33f55ff commit 171cebb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/sentry/db/models/manager/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from collections.abc import Callable, Collection, Generator, Mapping, MutableMapping, Sequence
from contextlib import contextmanager
from enum import IntEnum, auto
from typing import Any, Generic
from typing import TYPE_CHECKING, Any

from django.conf import settings
from django.db import models, router
Expand Down Expand Up @@ -42,8 +42,13 @@ class ModelManagerTriggerCondition(IntEnum):

ModelManagerTriggerAction = Callable[[type[Model]], None]

if TYPE_CHECKING:
_base_manager_base = DjangoBaseManager[M]
else:
_base_manager_base = DjangoBaseManager.from_queryset(BaseQuerySet)

class BaseManager(DjangoBaseManager.from_queryset(BaseQuerySet), Generic[M]): # type: ignore[misc]

class BaseManager(_base_manager_base[M]):
lookup_handlers = {"iexact": lambda x: x.upper()}
use_for_related_fields = True

Expand Down

0 comments on commit 171cebb

Please sign in to comment.