diff --git a/django-stubs-generated/apps/config.pyi b/django-stubs-generated/apps/config.pyi index fa92c43..277238f 100644 --- a/django-stubs-generated/apps/config.pyi +++ b/django-stubs-generated/apps/config.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterator, Optional, Type +from typing import Any, Iterator, Type from django.db.models.base import Model diff --git a/django-stubs-generated/apps/registry.pyi b/django-stubs-generated/apps/registry.pyi index a6bda9b..e0b6110 100644 --- a/django-stubs-generated/apps/registry.pyi +++ b/django-stubs-generated/apps/registry.pyi @@ -1,3 +1,4 @@ +import collections from typing import Any, Callable, List, Optional, Tuple, Type, Union from django.apps.config import AppConfig diff --git a/django-stubs-generated/conf/__init__.pyi b/django-stubs-generated/conf/__init__.pyi index 747b9b5..890d5ae 100644 --- a/django-stubs-generated/conf/__init__.pyi +++ b/django-stubs-generated/conf/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Union +from typing import Any, List, Optional, Union, Dict from django.utils.functional import LazyObject diff --git a/django-stubs-generated/conf/urls/i18n.pyi b/django-stubs-generated/conf/urls/i18n.pyi index 92bedee..45e3ca9 100644 --- a/django-stubs-generated/conf/urls/i18n.pyi +++ b/django-stubs-generated/conf/urls/i18n.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Tuple, Union +from typing import Any, List, Tuple, Union from django.urls.resolvers import URLPattern, URLResolver diff --git a/django-stubs-generated/conf/urls/static.pyi b/django-stubs-generated/conf/urls/static.pyi index e2ae241..92d0df7 100644 --- a/django-stubs-generated/conf/urls/static.pyi +++ b/django-stubs-generated/conf/urls/static.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, List, Optional +from typing import Any, Callable, List from django.urls.resolvers import URLPattern diff --git a/django-stubs-generated/db/models/__init__.pyi b/django-stubs-generated/db/models/__init__.pyi index b0ee0a6..94d9d18 100644 --- a/django-stubs-generated/db/models/__init__.pyi +++ b/django-stubs-generated/db/models/__init__.pyi @@ -59,7 +59,6 @@ from django.db.models.fields.proxy import OrderWrt # noinspection PyUnresolvedReferences from django.db.models.indexes import * # NOQA -# noinspection PyUnresolvedReferences from django.db.models.lookups import ( Lookup as Lookup, Transform as Transform diff --git a/django-stubs/contrib/postgres/fields/__init__.pyi b/django-stubs/contrib/postgres/fields/__init__.pyi index 879d1b7..c677ade 100644 --- a/django-stubs/contrib/postgres/fields/__init__.pyi +++ b/django-stubs/contrib/postgres/fields/__init__.pyi @@ -1 +1,3 @@ -from .array import ArrayField as ArrayField \ No newline at end of file +from .array import * # NOQA +from .jsonb import * # NOQA +from .ranges import * # NOQA diff --git a/django-stubs/contrib/postgres/fields/array.pyi b/django-stubs/contrib/postgres/fields/array.pyi index 56f0bcf..9df579f 100644 --- a/django-stubs/contrib/postgres/fields/array.pyi +++ b/django-stubs/contrib/postgres/fields/array.pyi @@ -1,14 +1,44 @@ -from typing import List, Any, TypeVar, Generic +from typing import Any, Dict, List, Optional, Tuple, Union, TypeVar, Generic -from django.contrib.postgres.fields.mixins import CheckFieldDefaultMixin -from django.db.models import Field +from django.db.models.fields import Field + +from .mixins import CheckFieldDefaultMixin _T = TypeVar('_T', bound=Field) class ArrayField(CheckFieldDefaultMixin, Field, Generic[_T]): - def __init__(self, - base_field: Field, - **kwargs): ... + empty_strings_allowed: bool = ... + default_error_messages: Any = ... + base_field: Any = ... + size: Any = ... + default_validators: Any = ... + from_db_value: Any = ... - def __get__(self, instance, owner) -> List[_T]: ... + def __init__( + self, base_field: Field, size: None = ..., **kwargs: Any + ) -> None: ... + @property + def model(self): ... + @model.setter + def model(self, model: Any) -> None: ... + def check(self, **kwargs: Any) -> List[Any]: ... + def set_attributes_from_name(self, name: str) -> None: ... + @property + def description(self): ... + def db_type(self, connection: Any): ... + def get_db_prep_value( + self, value: Any, connection: Any, prepared: bool = ... + ): ... + def deconstruct( + self + ) -> Tuple[ + None, str, List[Any], Dict[str, Optional[Union[bool, Field]]] + ]: ... + def to_python(self, value: Any): ... + def value_to_string(self, obj: Any): ... + def get_transform(self, name: Any): ... + def validate(self, value: Any, model_instance: Any) -> None: ... + def run_validators(self, value: Any) -> None: ... + def formfield(self, **kwargs: Any): ... + def __get__(self, instance, owner) -> List[_T]: ... \ No newline at end of file diff --git a/django-stubs/contrib/postgres/fields/jsonb.pyi b/django-stubs/contrib/postgres/fields/jsonb.pyi new file mode 100644 index 0000000..b4f7b12 --- /dev/null +++ b/django-stubs/contrib/postgres/fields/jsonb.pyi @@ -0,0 +1,41 @@ +from json import JSONEncoder +from typing import Any, Dict, List, Optional, Tuple, Type, Union + +from django.db.models import Field + +from .mixins import CheckFieldDefaultMixin + + +class JsonAdapter(object): + encoder: Any = ... + def __init__( + self, + adapted: Any, + dumps: Optional[Any] = ..., + encoder: Optional[Any] = ..., + ) -> None: ... + def dumps(self, obj: Any): ... + +class JSONField(CheckFieldDefaultMixin, Field): + empty_strings_allowed: bool = ... + description: Any = ... + default_error_messages: Any = ... + encoder: Any = ... + def __init__( + self, + verbose_name: None = ..., + name: None = ..., + encoder: Optional[Type[JSONEncoder]] = ..., + **kwargs: Any + ) -> None: ... + def db_type(self, connection: Any): ... + def deconstruct( + self + ) -> Tuple[ + None, str, List[Any], Dict[str, Union[Type[JSONEncoder], bool]] + ]: ... + def get_transform(self, name: Any): ... + def get_prep_value(self, value: Any): ... + def validate(self, value: Any, model_instance: Any) -> None: ... + def value_to_string(self, obj: Any): ... + def formfield(self, **kwargs: Any): ... \ No newline at end of file diff --git a/django-stubs/contrib/postgres/fields/mixins.pyi b/django-stubs/contrib/postgres/fields/mixins.pyi index a92ab36..cecac39 100644 --- a/django-stubs/contrib/postgres/fields/mixins.pyi +++ b/django-stubs/contrib/postgres/fields/mixins.pyi @@ -1,2 +1,5 @@ +from typing import Any, List, Optional + + class CheckFieldDefaultMixin: - pass \ No newline at end of file + def check(self, **kwargs: Any) -> List[Any]: ... diff --git a/django-stubs/contrib/postgres/fields/ranges.pyi b/django-stubs/contrib/postgres/fields/ranges.pyi new file mode 100644 index 0000000..877e0ab --- /dev/null +++ b/django-stubs/contrib/postgres/fields/ranges.pyi @@ -0,0 +1,48 @@ +from typing import Any + +from django.db import models + + +class RangeField(models.Field): + empty_strings_allowed: bool = ... + base_field: Any = ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + @property + def model(self): ... + @model.setter + def model(self, model: Any) -> None: ... + def get_prep_value(self, value: Any): ... + def to_python(self, value: Any): ... + def set_attributes_from_name(self, name: str) -> None: ... + def value_to_string(self, obj: Any): ... + def formfield(self, **kwargs: Any): ... + +class IntegerRangeField(RangeField): + base_field: Any = ... + range_type: Any = ... + form_field: Any = ... + def db_type(self, connection: Any): ... + +class BigIntegerRangeField(RangeField): + base_field: Any = ... + range_type: Any = ... + form_field: Any = ... + def db_type(self, connection: Any): ... + +class FloatRangeField(RangeField): + base_field: Any = ... + range_type: Any = ... + form_field: Any = ... + def db_type(self, connection: Any): ... + +class DateTimeRangeField(RangeField): + base_field: Any = ... + range_type: Any = ... + form_field: Any = ... + def db_type(self, connection: Any): ... + +class DateRangeField(RangeField): + base_field: Any = ... + range_type: Any = ... + form_field: Any = ... + def db_type(self, connection: Any): ... \ No newline at end of file diff --git a/django-stubs/contrib/postgres/operations.pyi b/django-stubs/contrib/postgres/operations.pyi new file mode 100644 index 0000000..20605cb --- /dev/null +++ b/django-stubs/contrib/postgres/operations.pyi @@ -0,0 +1,51 @@ +from typing import Any, Optional + +from django.db.backends.sqlite3.schema import DatabaseSchemaEditor +from django.db.migrations.operations.base import Operation +from django.db.migrations.state import ProjectState + + +class CreateExtension(Operation): + reversible: bool = ... + name: Any = ... + def __init__(self, name: str) -> None: ... + def state_forwards(self, app_label: str, state: ProjectState) -> None: ... + def database_forwards( + self, + app_label: str, + schema_editor: DatabaseSchemaEditor, + from_state: ProjectState, + to_state: ProjectState, + ) -> None: ... + def database_backwards( + self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any + ) -> None: ... + def describe(self): ... + +class BtreeGinExtension(CreateExtension): + name: str = ... + def __init__(self) -> None: ... + +class BtreeGistExtension(CreateExtension): + name: str = ... + def __init__(self) -> None: ... + +class CITextExtension(CreateExtension): + name: str = ... + def __init__(self) -> None: ... + +class CryptoExtension(CreateExtension): + name: str = ... + def __init__(self) -> None: ... + +class HStoreExtension(CreateExtension): + name: str = ... + def __init__(self) -> None: ... + +class TrigramExtension(CreateExtension): + name: str = ... + def __init__(self) -> None: ... + +class UnaccentExtension(CreateExtension): + name: str = ... + def __init__(self) -> None: ... diff --git a/django-stubs/db/models/__init__.pyi b/django-stubs/db/models/__init__.pyi index 2b9a19f..c099d9b 100644 --- a/django-stubs/db/models/__init__.pyi +++ b/django-stubs/db/models/__init__.pyi @@ -16,6 +16,9 @@ from .deletion import (CASCADE as CASCADE, SET_NULL as SET_NULL, DO_NOTHING as DO_NOTHING) -from .query import QuerySet as QuerySet +from .query import (QuerySet as QuerySet, + RawQuerySet as RawQuerySet) -from .query_utils import Q as Q \ No newline at end of file +from .query_utils import Q as Q + +from .lookups import (Lookup as Lookup) diff --git a/django-stubs/db/models/expressions.pyi b/django-stubs/db/models/expressions.pyi new file mode 100644 index 0000000..7ec57c3 --- /dev/null +++ b/django-stubs/db/models/expressions.pyi @@ -0,0 +1,179 @@ +from collections import OrderedDict +from datetime import datetime, timedelta +from typing import (Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, + Type, Union) + +from django.db.models.fields import Field +from django.db.models.lookups import Lookup +from django.db.models.sql.compiler import SQLCompiler + + +class SQLiteNumericMixin: + def as_sqlite( + self, + compiler: SQLCompiler, + connection: Any, + **extra_context: Any + ) -> Tuple[str, List[float]]: ... + + +class Combinable: + ADD: str = ... + SUB: str = ... + MUL: str = ... + DIV: str = ... + POW: str = ... + MOD: str = ... + BITAND: str = ... + BITOR: str = ... + BITLEFTSHIFT: str = ... + BITRIGHTSHIFT: str = ... + + def __neg__(self) -> CombinedExpression: ... + + def __add__( + self, other: Optional[Union[timedelta, Combinable, float, str]] + ) -> CombinedExpression: ... + + def __sub__( + self, other: Union[timedelta, Combinable, float] + ) -> CombinedExpression: ... + + def __mul__( + self, other: Union[timedelta, Combinable, float] + ) -> CombinedExpression: ... + + def __truediv__(self, other: float) -> CombinedExpression: ... + + def __mod__(self, other: int) -> CombinedExpression: ... + + def __pow__(self, other: float) -> CombinedExpression: ... + + def __and__(self, other: Combinable) -> Any: ... + + def bitand(self, other: int) -> CombinedExpression: ... + + def bitleftshift(self, other: int) -> CombinedExpression: ... + + def bitrightshift(self, other: int) -> CombinedExpression: ... + + def __or__(self, other: Combinable) -> Any: ... + + def bitor(self, other: int) -> CombinedExpression: ... + + def __radd__( + self, other: Optional[Union[datetime, float]] + ) -> CombinedExpression: ... + + def __rsub__(self, other: float) -> CombinedExpression: ... + + def __rmul__(self, other: float) -> CombinedExpression: ... + + def __rtruediv__(self, other: float) -> CombinedExpression: ... + + def __rmod__(self, other: int) -> CombinedExpression: ... + + def __rpow__(self, other: float) -> CombinedExpression: ... + + def __rand__(self, other: Any) -> Any: ... + + def __ror__(self, other: Any) -> Any: ... + + +class BaseExpression: + is_summary: bool = ... + filterable: bool = ... + window_compatible: bool = ... + + def __init__(self, output_field: Optional[Union[Field, str]] = ...) -> None: ... + + def get_db_converters(self, connection: Any) -> List[Callable]: ... + + def get_source_expressions(self) -> List[Any]: ... + + def set_source_expressions(self, exprs: List[Any]) -> None: ... + + def as_sql(self, compiler: Any, connection: Any) -> None: ... + + def contains_aggregate(self) -> bool: ... + + def contains_over_clause(self) -> bool: ... + + def contains_column_references(self) -> bool: ... + + def resolve_expression( + self, + query: Any = ..., + allow_joins: bool = ..., + reuse: Optional[Set[str]] = ..., + summarize: bool = ..., + for_save: bool = ..., + ) -> BaseExpression: ... + + @property + def field(self) -> Field: ... + + @property + def output_field(self) -> Field: ... + + def convert_value(self) -> Callable: ... + + def get_lookup(self, lookup: str) -> Optional[Type[Lookup]]: ... + + def get_transform(self, name: str) -> Optional[Type[Expression]]: ... + + def relabeled_clone( + self, change_map: Union[Dict[Optional[str], str], OrderedDict] + ) -> Expression: ... + + def copy(self) -> BaseExpression: ... + + def get_group_by_cols(self) -> List[Expression]: ... + + def get_source_fields(self) -> List[Optional[Field]]: ... + + def asc(self, **kwargs: Any) -> Expression: ... + + def desc(self, **kwargs: Any) -> Expression: ... + + def reverse_ordering(self): ... + + def flatten(self) -> Iterator[Expression]: ... + + def __eq__(self, other: object) -> bool: ... + + def __hash__(self) -> int: ... + + +class Expression(BaseExpression, Combinable): ... + + +class CombinedExpression(SQLiteNumericMixin, Expression): + connector: Any = ... + lhs: Any = ... + rhs: Any = ... + + def __init__( + self, + lhs: Combinable, + connector: str, + rhs: Combinable, + output_field: None = ..., + ) -> None: ... + + def get_source_expressions( + self + ) -> Union[List[Combinable], List[SQLiteNumericMixin]]: ... + + def set_source_expressions(self, exprs: List[Combinable]) -> None: ... + + def as_sql(self, compiler: SQLCompiler, connection: Any) -> Any: ... + + def resolve_expression( + self, + query: Any = ..., + allow_joins: bool = ..., + reuse: Optional[Set[str]] = ..., + summarize: bool = ..., + for_save: bool = ..., + ) -> CombinedExpression: ... diff --git a/django-stubs/db/models/lookups.pyi b/django-stubs/db/models/lookups.pyi new file mode 100644 index 0000000..5e16df2 --- /dev/null +++ b/django-stubs/db/models/lookups.pyi @@ -0,0 +1,70 @@ +from collections import OrderedDict +from typing import Any, Dict, List, Optional, Tuple, Union + +from django.db.models.expressions import Expression +from django.db.models.fields import TextField +from django.db.models.sql.compiler import SQLCompiler +from django.utils.datastructures import OrderedSet +from django.utils.safestring import SafeText + + +class Lookup: + lookup_name: Any = ... + prepare_rhs: bool = ... + can_use_none_as_rhs: bool = ... + lhs: Any = ... + rhs: Any = ... + bilateral_transforms: Any = ... + + def __init__( + self, + lhs: Union[Expression, TextField], + rhs: Any, + ) -> None: ... + + def apply_bilateral_transforms(self, value: Expression) -> Expression: ... + + def batch_process_rhs( + self, + compiler: SQLCompiler, + connection: Any, + rhs: Optional[OrderedSet] = ..., + ) -> Tuple[List[str], List[str]]: ... + + def get_source_expressions(self) -> List[Expression]: ... + + def set_source_expressions(self, new_exprs: List[Expression]) -> None: ... + + def get_prep_lookup(self) -> Any: ... + + def get_db_prep_lookup( + self, value: Union[int, str], connection: Any + ) -> Tuple[str, List[SafeText]]: ... + + def process_lhs( + self, + compiler: SQLCompiler, + connection: Any, + lhs: Optional[Expression] = ..., + ) -> Tuple[str, List[Union[int, str]]]: ... + + def process_rhs( + self, compiler: SQLCompiler, connection: Any + ) -> Tuple[str, Union[List[Union[int, str]], Tuple[int, int]]]: ... + + def rhs_is_direct_value(self) -> bool: ... + + def relabeled_clone( + self, relabels: Union[Dict[Optional[str], str], OrderedDict] + ) -> Lookup: ... + + def get_group_by_cols(self) -> List[Expression]: ... + + def as_sql(self, compiler: Any, connection: Any) -> None: ... + + def contains_aggregate(self) -> bool: ... + + def contains_over_clause(self) -> bool: ... + + @property + def is_summary(self): ... diff --git a/django-stubs/db/models/query.pyi b/django-stubs/db/models/query.pyi index b26ad45..dfe054b 100644 --- a/django-stubs/db/models/query.pyi +++ b/django-stubs/db/models/query.pyi @@ -174,4 +174,12 @@ class QuerySet(Generic[_T]): class RawQuerySet: + pass + + +class RawQuery(object): + pass + + +class Query(object): pass \ No newline at end of file diff --git a/django-stubs/db/models/sql/__init__.pyi b/django-stubs/db/models/sql/__init__.pyi new file mode 100644 index 0000000..a821d5a --- /dev/null +++ b/django-stubs/db/models/sql/__init__.pyi @@ -0,0 +1,2 @@ +from ..query import (Query as Query, + RawQuery as RawQuery) \ No newline at end of file diff --git a/django-stubs/db/models/sql/compiler.pyi b/django-stubs/db/models/sql/compiler.pyi new file mode 100644 index 0000000..1243f28 --- /dev/null +++ b/django-stubs/db/models/sql/compiler.pyi @@ -0,0 +1,193 @@ +from datetime import date, datetime +from decimal import Decimal +from itertools import chain +from typing import (Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, + Type, Union) +from uuid import UUID + +from django.db.models.base import Model +from django.db.models.expressions import BaseExpression, Expression +from django.db.models.sql import Query, RawQuery + +FORCE: Any + + +class SQLCompiler: + query: Any = ... + connection: Any = ... + using: Any = ... + quote_cache: Any = ... + select: Any = ... + annotation_col_map: Any = ... + klass_info: Any = ... + ordering_parts: Any = ... + + def __init__( + self, + query: Union[Query, RawQuery], + connection: Any, + using: Optional[str], + ) -> None: ... + + col_count: Any = ... + + def setup_query(self) -> None: ... + + has_extra_select: Any = ... + + def pre_sql_setup( + self + ) -> Tuple[ + List[ + Tuple[Expression, Tuple[str, Union[List[Any], Tuple[str, str]]], None] + ], + List[Tuple[Expression, Tuple[str, List[Union[int, str]], bool]]], + List[Tuple[str, List[float]]], + ]: ... + + def get_group_by( + self, + select: List[ + Tuple[ + BaseExpression, + Tuple[str, List[float]], + Optional[str], + ] + ], + order_by: List[Tuple[Expression, Tuple[str, List[Union[int, str]], bool]]], + ) -> List[Tuple[str, List[float]]]: ... + + def collapse_group_by( + self, + expressions: List[Expression], + having: Union[List[Expression], Tuple], + ) -> List[Expression]: ... + + def get_select( + self + ) -> Tuple[ + List[ + Tuple[ + Expression, + Tuple[str, List[Union[int, str]]], + Optional[str], + ] + ], + Optional[ + Dict[str, Any] + ], + Dict[str, int], + ]: ... + + def get_order_by( + self + ) -> List[Tuple[Expression, Tuple[str, List[Any], bool]]]: ... + + def get_extra_select( + self, + order_by: List[Tuple[Expression, Tuple[str, List[Any], bool]]], + select: List[ + Tuple[ + Expression, + Tuple[str, List[float]], + Optional[str], + ] + ], + ) -> List[Tuple[Expression, Tuple[str, List[Any]], None]]: ... + + def quote_name_unless_alias(self, name: str) -> str: ... + + def compile( + self, node: Any, select_format: Any = ... + ) -> Tuple[str, Union[List[Optional[int]], Tuple[int, int]]]: ... + + def get_combinator_sql( + self, combinator: str, all: bool + ) -> Tuple[List[str], Union[List[int], List[str]]]: ... + + def as_sql( + self, with_limits: bool = ..., with_col_aliases: bool = ... + ) -> Any: ... + + def get_default_columns( + self, + start_alias: Optional[str] = ..., + opts: Optional[Any] = ..., + from_parent: Optional[Type[Model]] = ..., + ) -> List[Expression]: ... + + def get_distinct(self) -> Tuple[List[Any], List[Any]]: ... + + def find_ordering_name( + self, + name: str, + opts: Any, + alias: Optional[str] = ..., + default_order: str = ..., + already_seen: Optional[ + Set[Tuple[Optional[Tuple[Tuple[str, str]]], Tuple[Tuple[str, str]]]] + ] = ..., + ) -> List[Tuple[Expression, bool]]: ... + + def get_from_clause(self) -> Tuple[List[str], List[Union[int, str]]]: ... + + def get_related_selections( + self, + select: List[Tuple[Expression, Optional[str]]], + opts: Optional[Any] = ..., + root_alias: Optional[str] = ..., + cur_depth: int = ..., + requested: Optional[ + Union[Dict[str, Dict[str, Dict[str, Dict[Any, Any]]]], bool] + ] = ..., + restricted: Optional[bool] = ..., + ) -> List[Dict[str, Any]]: ... + + def get_select_for_update_of_arguments(self): ... + + def deferred_to_columns(self) -> Dict[Type[Model], Set[str]]: ... + + def get_converters( + self, expressions: List[Expression] + ) -> Dict[ + int, Tuple[List[Callable], Expression] + ]: ... + + def apply_converters( + self, + rows: chain, + converters: Dict[ + int, Tuple[List[Callable], Expression] + ], + ) -> Iterator[ + Union[ + List[Optional[Union[bytes, datetime, int, str]]], + List[Optional[Union[date, Decimal, float, str]]], + List[Optional[Union[datetime, float, str, UUID]]], + ] + ]: ... + + def results_iter( + self, + results: Optional[ + Union[Iterator[Any], List[List[Tuple[Union[int, str]]]]] + ] = ..., + tuple_expected: bool = ..., + chunked_fetch: bool = ..., + chunk_size: int = ..., + ) -> Iterator[Any]: ... + + def has_results(self) -> bool: ... + + def execute_sql( + self, + result_type: str = ..., + chunked_fetch: bool = ..., + chunk_size: int = ..., + ) -> Optional[Any]: ... + + def as_subquery_condition( + self, alias: str, columns: List[str], compiler: SQLCompiler + ) -> Tuple[str, Tuple]: ... + + def explain_query(self) -> Iterator[str]: ... diff --git a/django-stubs/utils/datastructures.pyi b/django-stubs/utils/datastructures.pyi index aa3a6dd..61cd794 100644 --- a/django-stubs/utils/datastructures.pyi +++ b/django-stubs/utils/datastructures.pyi @@ -2,7 +2,7 @@ from collections import OrderedDict -from typing import (Any, Callable, Dict, Generic, Hashable, Iterable, Iterator, List, Mapping, +from typing import (Any, Callable, Dict, Generic, Iterable, Iterator, List, Mapping, MutableMapping, MutableSet, Optional, overload, Tuple, TypeVar, Union) KT = TypeVar('KT') @@ -14,6 +14,9 @@ class OrderedSet(MutableSet[KT], Generic[KT]): def add(self, item: KT) -> None: ... def remove(self, item: KT) -> None: ... def discard(self, item: KT) -> None: ... + def __contains__(self, item): ... + def __iter__(self): ... + def __len__(self): ... class MultiValueDictKeyError(KeyError): ... diff --git a/django-stubs/utils/safestring.pyi b/django-stubs/utils/safestring.pyi new file mode 100644 index 0000000..d7c4918 --- /dev/null +++ b/django-stubs/utils/safestring.pyi @@ -0,0 +1,19 @@ +from typing import Any + + +class SafeData: + def __html__(self) -> SafeText: ... + + +class SafeBytes(bytes, SafeData): + def __add__(self, rhs: Any): ... + + +class SafeText(str, SafeData): + def __add__(self, rhs: str) -> str: ... + + +SafeString = SafeText + + +def mark_safe(s: Any) -> Any: ...