Skip to content

Commit

Permalink
Merge pull request #1039 from max-muoto/improve-typing-for-filter-schema
Browse files Browse the repository at this point in the history
Minor Typing Improvement for `FilterSchema`
  • Loading branch information
vitalik authored Jan 7, 2024
2 parents 451b2fb + baaa808 commit 5a7c7cd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ninja/filter_schema.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, cast
from typing import Any, TypeVar, cast

from django.core.exceptions import ImproperlyConfigured
from django.db.models import Q, QuerySet
Expand All @@ -22,6 +22,9 @@
# )


T = TypeVar("T", bound=QuerySet)


class FilterSchema(Schema):
# if TYPE_CHECKING:
# __config__: ClassVar[Type[FilterConfig]] = FilterConfig # pragma: no cover
Expand Down Expand Up @@ -49,7 +52,7 @@ def get_filter_expression(self) -> Q:
except NotImplementedError:
return self._connect_fields()

def filter(self, queryset: QuerySet) -> QuerySet:
def filter(self, queryset: T) -> T:
return queryset.filter(self.get_filter_expression())

def _resolve_field_expression(
Expand Down

0 comments on commit 5a7c7cd

Please sign in to comment.