Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove generic argument of django.db.models.lookups.Lookup #2205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 25 additions & 27 deletions django-stubs/db/models/lookups.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Iterable
from typing import Any, Generic, Literal, Sequence, TypeVar
from typing import Any, Literal, Sequence

from django.core.exceptions import EmptyResultSet
from django.db.backends.base.base import BaseDatabaseWrapper
Expand All @@ -10,9 +10,7 @@ from django.db.models.sql.compiler import SQLCompiler, _AsSqlType, _ParamT
from django.utils.datastructures import OrderedSet
from django.utils.functional import cached_property

_T = TypeVar("_T")

class Lookup(Expression, Generic[_T]):
class Lookup(Expression):
lookup_name: str
prepare_rhs: bool
can_use_none_as_rhs: bool
Expand Down Expand Up @@ -50,7 +48,7 @@ class Transform(RegisterLookupMixin, Func):
def lhs(self) -> Expression: ...
def get_bilateral_transforms(self) -> list[type[Transform]]: ...

class BuiltinLookup(Lookup[_T]):
class BuiltinLookup(Lookup):
def process_lhs(
self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, lhs: Expression | None = ...
) -> _AsSqlType: ...
Expand All @@ -67,16 +65,16 @@ class FieldGetDbPrepValueIterableMixin(FieldGetDbPrepValueMixin):
self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, sql: str, param: Any
) -> _AsSqlType: ...

class PostgresOperatorLookup(Lookup[_T]):
class PostgresOperatorLookup(Lookup):
postgres_operator: str | None
def as_postgresql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ...

class Exact(FieldGetDbPrepValueMixin, BuiltinLookup[_T]): ...
class IExact(BuiltinLookup[_T]): ...
class GreaterThan(FieldGetDbPrepValueMixin, BuiltinLookup[_T]): ...
class GreaterThanOrEqual(FieldGetDbPrepValueMixin, BuiltinLookup[_T]): ...
class LessThan(FieldGetDbPrepValueMixin, BuiltinLookup[_T]): ...
class LessThanOrEqual(FieldGetDbPrepValueMixin, BuiltinLookup[_T]): ...
class Exact(FieldGetDbPrepValueMixin, BuiltinLookup): ...
class IExact(BuiltinLookup): ...
class GreaterThan(FieldGetDbPrepValueMixin, BuiltinLookup): ...
class GreaterThanOrEqual(FieldGetDbPrepValueMixin, BuiltinLookup): ...
class LessThan(FieldGetDbPrepValueMixin, BuiltinLookup): ...
class LessThanOrEqual(FieldGetDbPrepValueMixin, BuiltinLookup): ...

class IntegerFieldOverflow:
underflow_exception: type[EmptyResultSet]
Expand All @@ -87,16 +85,16 @@ class IntegerFieldFloatRounding:
rhs: Any
def get_prep_lookup(self) -> Any: ...

class IntegerFieldExact(IntegerFieldOverflow, Exact[int | float]): ...
class IntegerGreaterThan(IntegerFieldOverflow, GreaterThan[int | float]): ...
class IntegerGreaterThanOrEqual(IntegerFieldOverflow, IntegerFieldFloatRounding, GreaterThanOrEqual[int | float]): ...
class IntegerLessThan(IntegerFieldOverflow, IntegerFieldFloatRounding, LessThan[int | float]): ...
class IntegerLessThanOrEqual(IntegerFieldOverflow, LessThanOrEqual[int | float]): ...
class IntegerFieldExact(IntegerFieldOverflow, Exact): ...
class IntegerGreaterThan(IntegerFieldOverflow, GreaterThan): ...
class IntegerGreaterThanOrEqual(IntegerFieldOverflow, IntegerFieldFloatRounding, GreaterThanOrEqual): ...
class IntegerLessThan(IntegerFieldOverflow, IntegerFieldFloatRounding, LessThan): ...
class IntegerLessThanOrEqual(IntegerFieldOverflow, LessThanOrEqual): ...

class In(FieldGetDbPrepValueIterableMixin, BuiltinLookup):
def split_parameter_list_as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> Any: ...

class PatternLookup(BuiltinLookup[str]):
class PatternLookup(BuiltinLookup):
param_pattern: str

class Contains(PatternLookup): ...
Expand All @@ -105,36 +103,36 @@ class StartsWith(PatternLookup): ...
class IStartsWith(StartsWith): ...
class EndsWith(PatternLookup): ...
class IEndsWith(EndsWith): ...
class Range(FieldGetDbPrepValueIterableMixin, BuiltinLookup[_T]): ...
class IsNull(BuiltinLookup[bool]): ...
class Regex(BuiltinLookup[str]): ...
class Range(FieldGetDbPrepValueIterableMixin, BuiltinLookup): ...
class IsNull(BuiltinLookup): ...
class Regex(BuiltinLookup): ...
class IRegex(Regex): ...

class YearLookup(Lookup):
def year_lookup_bounds(self, connection: BaseDatabaseWrapper, year: int) -> list[str]: ...
def get_direct_rhs_sql(self, connection: BaseDatabaseWrapper, rhs: str) -> str: ...
def get_bound_params(self, start: Any, finish: Any) -> Any: ...

class YearExact(YearLookup, Exact[_T]):
class YearExact(YearLookup, Exact):
def get_bound_params(self, start: Any, finish: Any) -> tuple[Any, Any]: ...

class YearGt(YearLookup, GreaterThan[_T]):
class YearGt(YearLookup, GreaterThan):
def get_bound_params(self, start: Any, finish: Any) -> tuple[Any]: ...

class YearGte(YearLookup, GreaterThanOrEqual[_T]):
class YearGte(YearLookup, GreaterThanOrEqual):
def get_bound_params(self, start: Any, finish: Any) -> tuple[Any]: ...

class YearLt(YearLookup, LessThan[_T]):
class YearLt(YearLookup, LessThan):
def get_bound_params(self, start: Any, finish: Any) -> tuple[Any]: ...

class YearLte(YearLookup, LessThanOrEqual[_T]):
class YearLte(YearLookup, LessThanOrEqual):
def get_bound_params(self, start: Any, finish: Any) -> tuple[Any]: ...

class UUIDTextMixin:
rhs: Any
def process_rhs(self, qn: Any, connection: BaseDatabaseWrapper) -> Any: ...

class UUIDIExact(UUIDTextMixin, IExact[_T]): ...
class UUIDIExact(UUIDTextMixin, IExact): ...
class UUIDContains(UUIDTextMixin, Contains): ...
class UUIDIContains(UUIDTextMixin, IContains): ...
class UUIDStartsWith(UUIDTextMixin, StartsWith): ...
Expand Down
Loading