File: ranges.pyi

package info (click to toggle)
python-django-stubs 5.2.9-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,832 kB
  • sloc: python: 5,185; makefile: 15; sh: 8
file content (102 lines) | stat: -rw-r--r-- 3,386 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
from typing import Any, ClassVar, Literal, TypeVar

from _typeshed import Unused
from django.contrib.postgres import forms
from django.db import models
from django.db.backends.base.base import BaseDatabaseWrapper
from django.db.models.lookups import PostgresOperatorLookup
from django.db.models.sql.compiler import SQLCompiler, _AsSqlType
from psycopg2.extras import DateRange, DateTimeTZRange, NumericRange, Range  # type: ignore [import-untyped]

class RangeBoundary(models.Expression):
    lower: str
    upper: str
    def __init__(self, inclusive_lower: bool = ..., inclusive_upper: bool = ...) -> None: ...

class RangeOperators:
    EQUAL: Literal["="]
    NOT_EQUAL: Literal["<>"]
    CONTAINS: Literal["@>"]
    CONTAINED_BY: Literal["<@"]
    OVERLAPS: Literal["&&"]
    FULLY_LT: Literal["<<"]
    FULLY_GT: Literal[">>"]
    NOT_LT: Literal["&>"]
    NOT_GT: Literal["&<"]
    ADJACENT_TO: Literal["-|-"]

_RangeT = TypeVar("_RangeT", bound=Range[Any])

class RangeField(models.Field[Any, _RangeT]):
    empty_strings_allowed: bool
    base_field: type[models.Field]
    range_type: type[_RangeT]
    def get_prep_value(self, value: Any) -> Any | None: ...
    def get_placeholder(self, value: Unused, compiler: Unused, connection: BaseDatabaseWrapper) -> str: ...
    def to_python(self, value: Any) -> Any: ...

class IntegerRangeField(RangeField[NumericRange]):
    base_field: type[models.IntegerField]
    form_field: type[forms.IntegerRangeField]

class BigIntegerRangeField(RangeField[NumericRange]):
    base_field: type[models.BigIntegerField]
    form_field: type[forms.IntegerRangeField]

class DecimalRangeField(RangeField[NumericRange]):
    base_field: type[models.DecimalField]
    form_field: type[forms.DecimalRangeField]

class DateTimeRangeField(RangeField[DateTimeTZRange]):
    base_field: type[models.DateTimeField]
    form_field: type[forms.DateTimeRangeField]

class DateRangeField(RangeField[DateRange]):
    base_field: type[models.DateField]
    form_field: type[forms.DateRangeField]

class DateTimeRangeContains(PostgresOperatorLookup): ...

class RangeContainedBy(PostgresOperatorLookup):
    type_mapping: dict[str, str]
    def process_lhs(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ...  # type: ignore[override]

class FullyLessThan(PostgresOperatorLookup): ...
class FullGreaterThan(PostgresOperatorLookup): ...
class NotLessThan(PostgresOperatorLookup): ...
class NotGreaterThan(PostgresOperatorLookup): ...
class AdjacentToLookup(PostgresOperatorLookup): ...

class RangeStartsWith(models.Transform):
    @property
    def output_field(self) -> models.Field: ...

class RangeEndsWith(models.Transform):
    @property
    def output_field(self) -> models.Field: ...

class IsEmpty(models.Transform):
    output_field: ClassVar[models.BooleanField]

class LowerInclusive(models.Transform):
    output_field: ClassVar[models.BooleanField]

class LowerInfinite(models.Transform):
    output_field: ClassVar[models.BooleanField]

class UpperInclusive(models.Transform):
    output_field: ClassVar[models.BooleanField]

class UpperInfinite(models.Transform):
    output_field: ClassVar[models.BooleanField]

__all__ = [
    "BigIntegerRangeField",
    "DateRangeField",
    "DateTimeRangeField",
    "DecimalRangeField",
    "IntegerRangeField",
    "RangeBoundary",
    "RangeField",
    "RangeOperators",
]