diff --git a/django-stubs/contrib/admin/options.pyi b/django-stubs/contrib/admin/options.pyi index 17500b7be..8b5ed1427 100644 --- a/django-stubs/contrib/admin/options.pyi +++ b/django-stubs/contrib/admin/options.pyi @@ -15,6 +15,7 @@ from typing import ( TypeVar, Union, ) +from typing_extensions import Literal, TypedDict from django.contrib.admin.filters import ListFilter from django.contrib.admin.models import LogEntry @@ -47,7 +48,6 @@ from django.http.response import ( from django.template.response import TemplateResponse from django.urls.resolvers import URLPattern from django.utils.safestring import SafeText -from typing_extensions import Literal, TypedDict IS_POPUP_VAR: str TO_FIELD_VAR: str diff --git a/django-stubs/contrib/auth/base_user.pyi b/django-stubs/contrib/auth/base_user.pyi index 3d87ab57d..bcaa0f202 100644 --- a/django-stubs/contrib/auth/base_user.pyi +++ b/django-stubs/contrib/auth/base_user.pyi @@ -1,15 +1,10 @@ -import sys from typing import Any, List, Optional, Tuple, TypeVar, Union, overload +from typing_extensions import Literal from django.db import models from django.db.models.base import Model from django.db.models.fields import BooleanField -if sys.version_info < (3, 8): - from typing_extensions import Literal -else: - from typing import Literal - _T = TypeVar("_T", bound=Model) class BaseUserManager(models.Manager[_T]): diff --git a/django-stubs/contrib/auth/models.pyi b/django-stubs/contrib/auth/models.pyi index 2471203c2..6af6d8ec0 100644 --- a/django-stubs/contrib/auth/models.pyi +++ b/django-stubs/contrib/auth/models.pyi @@ -1,5 +1,5 @@ -import sys from typing import Any, ClassVar, Collection, Optional, Set, Tuple, Type, TypeVar, Union +from typing_extensions import Literal, Self from django.contrib.auth.backends import ModelBackend from django.contrib.auth.base_user import AbstractBaseUser as AbstractBaseUser @@ -10,16 +10,6 @@ from django.db import models from django.db.models.base import Model from django.db.models.manager import EmptyManager -if sys.version_info < (3, 8): - from typing_extensions import Literal -else: - from typing import Literal - -if sys.version_info < (3, 11): - from typing_extensions import Self -else: - from typing import Self - _AnyUser = Union[Model, "AnonymousUser"] def update_last_login( diff --git a/django-stubs/contrib/contenttypes/fields.pyi b/django-stubs/contrib/contenttypes/fields.pyi index 3239d176e..7089ca553 100644 --- a/django-stubs/contrib/contenttypes/fields.pyi +++ b/django-stubs/contrib/contenttypes/fields.pyi @@ -1,4 +1,5 @@ from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union +from typing_extensions import Self from django.contrib.contenttypes.models import ContentType from django.core.checks.messages import CheckMessage @@ -84,7 +85,7 @@ class GenericRelation(ForeignObject[Any]): content_type_field_name: Any = ... for_concrete_model: Any = ... to_fields: Any = ... - def __new__(cls, *args: Any, **kwargs: Any) -> GenericRelation: ... + def __new__(cls, *args: Any, **kwargs: Any) -> Self: ... def __init__( self, to: Union[Type[Model], str], diff --git a/django-stubs/contrib/humanize/templatetags/humanize.pyi b/django-stubs/contrib/humanize/templatetags/humanize.pyi index cde290de8..bf005a559 100644 --- a/django-stubs/contrib/humanize/templatetags/humanize.pyi +++ b/django-stubs/contrib/humanize/templatetags/humanize.pyi @@ -1,6 +1,6 @@ from datetime import date from datetime import datetime as datetime -from typing import Any, Callable, Dict, Optional, SupportsInt, Tuple, Type, Union +from typing import Any, Callable, Dict, Optional, SupportsInt, Tuple, Union from django import template @@ -21,4 +21,4 @@ class NaturalTimeFormatter: past_substrings: Dict[str, str] future_substrings: Dict[str, str] @classmethod - def string_for(cls: Type[NaturalTimeFormatter], value: Any) -> Any: ... + def string_for(cls, value: Any) -> Any: ... diff --git a/django-stubs/contrib/postgres/fields/array.pyi b/django-stubs/contrib/postgres/fields/array.pyi index 5f9560dd3..9936a038c 100644 --- a/django-stubs/contrib/postgres/fields/array.pyi +++ b/django-stubs/contrib/postgres/fields/array.pyi @@ -10,10 +10,10 @@ from typing import ( Union, overload, ) +from typing_extensions import Literal from django.db.models.expressions import Combinable from django.db.models.fields import Field, _ErrorMessagesToOverride, _ValidatorCallable -from typing_extensions import Literal from .mixins import CheckFieldDefaultMixin diff --git a/django-stubs/contrib/postgres/fields/citext.pyi b/django-stubs/contrib/postgres/fields/citext.pyi index 4630f3063..4bb8d2b4e 100644 --- a/django-stubs/contrib/postgres/fields/citext.pyi +++ b/django-stubs/contrib/postgres/fields/citext.pyi @@ -9,9 +9,9 @@ from typing import ( Union, overload, ) +from typing_extensions import Literal from django.db.models.fields import CharField, EmailField, TextField -from typing_extensions import Literal _Choice = Tuple[Any, Any] _ChoiceNamedGroup = Tuple[str, Iterable[_Choice]] @@ -75,8 +75,8 @@ class CICharField(CIText, CharField[_C]): validators: Iterable[_ValidatorCallable] = ..., error_messages: Optional[_ErrorMessagesToOverride] = ..., ) -> None: ... - def __get__(self: CICharField[_C], instance: Any, owner: Any) -> _C: ... - def __set__(self: CICharField[_C], instance: Any, value: _C) -> None: ... # type: ignore [override] + def __get__(self, instance: Any, owner: Any) -> _C: ... + def __set__(self, instance: Any, value: _C) -> None: ... # type: ignore [override] class CIEmailField(CIText, EmailField[_C]): @overload @@ -129,7 +129,7 @@ class CIEmailField(CIText, EmailField[_C]): validators: Iterable[_ValidatorCallable] = ..., error_messages: Optional[_ErrorMessagesToOverride] = ..., ) -> None: ... - def __get__(self: CIEmailField[_C], instance: Any, owner: Any) -> _C: ... + def __get__(self, instance: Any, owner: Any) -> _C: ... def __set__(self, instance: Any, value: _C) -> None: ... # type: ignore [override] class CITextField(CIText, TextField[_C]): @@ -183,5 +183,5 @@ class CITextField(CIText, TextField[_C]): validators: Iterable[_ValidatorCallable] = ..., error_messages: Optional[_ErrorMessagesToOverride] = ..., ) -> None: ... - def __get__(self: CITextField[_C], instance: Any, owner: Any) -> _C: ... - def __set__(self: CITextField[_C], instance: Any, value: _C) -> None: ... # type: ignore [override] + def __get__(self, instance: Any, owner: Any) -> _C: ... + def __set__(self, instance: Any, value: _C) -> None: ... # type: ignore [override] diff --git a/django-stubs/contrib/postgres/fields/hstore.pyi b/django-stubs/contrib/postgres/fields/hstore.pyi index e248ef416..5abe72a4b 100644 --- a/django-stubs/contrib/postgres/fields/hstore.pyi +++ b/django-stubs/contrib/postgres/fields/hstore.pyi @@ -10,9 +10,9 @@ from typing import ( Union, overload, ) +from typing_extensions import Literal from django.db.models import Field, Transform -from typing_extensions import Literal from .mixins import CheckFieldDefaultMixin @@ -76,8 +76,8 @@ class HStoreField(Generic[_T], CheckFieldDefaultMixin, Field[Any, Any]): error_messages: Optional[_ErrorMessagesToOverride] = ..., ) -> None: ... def get_transform(self, name: Any) -> Any: ... - def __get__(self: HStoreField[_T], instance: Any, owner: Any) -> _T: ... - def __set__(self: HStoreField[_T], instance: Any, value: _T) -> None: ... + def __get__(self, instance: Any, owner: Any) -> _T: ... + def __set__(self, instance: Any, value: _T) -> None: ... class KeyTransform(Transform): def __init__(self, key_name: str, *args: Any, **kwargs: Any) -> None: ... diff --git a/django-stubs/contrib/postgres/search.pyi b/django-stubs/contrib/postgres/search.pyi index 455c997fa..af5b779d9 100644 --- a/django-stubs/contrib/postgres/search.pyi +++ b/django-stubs/contrib/postgres/search.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Iterable, Optional, TypeVar, Union +from typing import Any, Dict, Iterable, Optional, Union +from typing_extensions import Self from django.db.models import Field from django.db.models.expressions import ( @@ -88,15 +89,13 @@ class CombinedSearchVector(SearchVectorCombinable, CombinedExpression): output_field: Optional[_OutputField] = ..., ) -> None: ... -_T = TypeVar("_T", bound="SearchQueryCombinable") - class SearchQueryCombinable: BITAND: str = ... BITOR: str = ... - def __or__(self: _T, other: SearchQueryCombinable) -> _T: ... - def __ror__(self: _T, other: SearchQueryCombinable) -> _T: ... - def __and__(self: _T, other: SearchQueryCombinable) -> _T: ... - def __rand__(self: _T, other: SearchQueryCombinable) -> _T: ... + def __or__(self, other: SearchQueryCombinable) -> Self: ... + def __ror__(self, other: SearchQueryCombinable) -> Self: ... + def __and__(self, other: SearchQueryCombinable) -> Self: ... + def __rand__(self, other: SearchQueryCombinable) -> Self: ... class SearchQuery(SearchQueryCombinable, Value): # type: ignore SEARCH_TYPES: Dict[str, str] = ... @@ -109,7 +108,7 @@ class SearchQuery(SearchQueryCombinable, Value): # type: ignore invert: bool = ..., search_type: str = ... ) -> None: ... - def __invert__(self: _T) -> _T: ... + def __invert__(self) -> Self: ... class CombinedSearchQuery(SearchQueryCombinable, CombinedExpression): # type: ignore def __init__( diff --git a/django-stubs/contrib/staticfiles/finders.pyi b/django-stubs/contrib/staticfiles/finders.pyi index 1e4dfc4a3..3de94200c 100644 --- a/django-stubs/contrib/staticfiles/finders.pyi +++ b/django-stubs/contrib/staticfiles/finders.pyi @@ -1,8 +1,8 @@ from typing import Any, Iterable, Iterator, List, Mapping, Optional, Union, overload +from typing_extensions import Literal from django.core.checks.messages import CheckMessage from django.core.files.storage import Storage -from typing_extensions import Literal searched_locations: Any diff --git a/django-stubs/core/files/base.pyi b/django-stubs/core/files/base.pyi index c99376e6e..2374d4474 100644 --- a/django-stubs/core/files/base.pyi +++ b/django-stubs/core/files/base.pyi @@ -1,11 +1,10 @@ import types from io import StringIO -from typing import IO, Any, Iterator, Optional, Type, TypeVar, Union +from typing import IO, Any, Iterator, Optional, Type, Union +from typing_extensions import Self from django.core.files.utils import FileProxyMixin -_T = TypeVar("_T", bound="File") - class File(FileProxyMixin, IO[Any]): DEFAULT_CHUNK_SIZE: Any = ... file: IO[Any] = ... @@ -20,14 +19,14 @@ class File(FileProxyMixin, IO[Any]): def multiple_chunks(self, chunk_size: Optional[int] = ...) -> bool: ... def __iter__(self) -> Iterator[Union[bytes, str]]: ... def __next__(self) -> Union[bytes, str]: ... - def __enter__(self: _T) -> _T: ... + def __enter__(self) -> Self: ... def __exit__( self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], tb: Optional[types.TracebackType], ) -> None: ... - def open(self: _T, mode: Optional[str] = ...) -> _T: ... + def open(self, mode: Optional[str] = ...) -> Self: ... def close(self) -> None: ... class ContentFile(File): diff --git a/django-stubs/core/files/uploadedfile.pyi b/django-stubs/core/files/uploadedfile.pyi index f5c6632e5..a7117bbb2 100644 --- a/django-stubs/core/files/uploadedfile.pyi +++ b/django-stubs/core/files/uploadedfile.pyi @@ -45,4 +45,4 @@ class SimpleUploadedFile(InMemoryUploadedFile): self, name: str, content: Optional[Union[bytes, str]], content_type: str = ... ) -> None: ... @classmethod - def from_dict(cls: Any, file_dict: Dict[str, Union[str, bytes]]) -> None: ... + def from_dict(cls, file_dict: Dict[str, Union[str, bytes]]) -> None: ... diff --git a/django-stubs/core/mail/backends/base.pyi b/django-stubs/core/mail/backends/base.pyi index 81d430383..1b74fb836 100644 --- a/django-stubs/core/mail/backends/base.pyi +++ b/django-stubs/core/mail/backends/base.pyi @@ -1,15 +1,14 @@ import types -from typing import Any, Iterable, Optional, Type, TypeVar +from typing import Any, Iterable, Optional, Type +from typing_extensions import Self from django.core.mail.message import EmailMessage -_T = TypeVar("_T", bound="BaseEmailBackend") - class BaseEmailBackend: def __init__(self, fail_silently: bool = ..., **kwargs: Any) -> None: ... def open(self) -> Optional[bool]: ... def close(self) -> None: ... - def __enter__(self: _T) -> _T: ... + def __enter__(self) -> Self: ... def __exit__( self, exc_type: Type[BaseException], diff --git a/django-stubs/db/backends/utils.pyi b/django-stubs/db/backends/utils.pyi index 4b8f23622..6d2580a88 100644 --- a/django-stubs/db/backends/utils.pyi +++ b/django-stubs/db/backends/utils.pyi @@ -14,12 +14,12 @@ from typing import ( Type, Union, ) +from typing_extensions import Literal from uuid import UUID import psycopg2 from django.db.backends.postgresql.base import DatabaseWrapper from psycopg2.extensions import Column -from typing_extensions import Literal logger: Any diff --git a/django-stubs/db/migrations/migration.pyi b/django-stubs/db/migrations/migration.pyi index 1468ea557..8ed08a0df 100644 --- a/django-stubs/db/migrations/migration.pyi +++ b/django-stubs/db/migrations/migration.pyi @@ -1,4 +1,5 @@ from typing import List, Optional, Tuple +from typing_extensions import Self from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.migrations.operations.base import Operation @@ -32,6 +33,6 @@ class Migration: class SwappableTuple(Tuple[str, str]): setting: str = ... - def __new__(cls, value: Tuple[str, str], setting: str) -> SwappableTuple: ... + def __new__(cls, value: Tuple[str, str], setting: str) -> Self: ... def swappable_dependency(value: str) -> SwappableTuple: ... diff --git a/django-stubs/db/models/base.pyi b/django-stubs/db/models/base.pyi index e79278c99..10fc7a961 100644 --- a/django-stubs/db/models/base.pyi +++ b/django-stubs/db/models/base.pyi @@ -1,4 +1,3 @@ -import sys from typing import ( Any, Callable, @@ -11,9 +10,9 @@ from typing import ( Set, Tuple, Type, - TypeVar, Union, ) +from typing_extensions import Self from django.core.checks.messages import CheckMessage from django.core.exceptions import ( @@ -23,14 +22,6 @@ from django.core.exceptions import ObjectDoesNotExist, ValidationError from django.db.models.manager import BaseManager from django.db.models.options import Options -if sys.version_info < (3, 11): - from typing_extensions import Self -else: - from typing import Self - -_M = TypeVar("_M", bound=Any) -_Self = TypeVar("_Self", bound="Model") - class ModelStateFieldsCacheDescriptor: ... class ModelState: @@ -55,11 +46,8 @@ class Model(metaclass=ModelBase): def add_to_class(cls, name: str, value: Any) -> Any: ... @classmethod def from_db( - cls: Type[_Self], - db: Optional[str], - field_names: Collection[str], - values: Collection[Any], - ) -> _Self: ... + cls, db: Optional[str], field_names: Collection[str], values: Collection[Any] + ) -> Self: ... def delete( self, using: Any = ..., keep_parents: bool = ... ) -> Tuple[int, Dict[str, int]]: ... @@ -76,8 +64,8 @@ class Model(metaclass=ModelBase): def clean_fields(self, exclude: Optional[Collection[str]] = ...) -> None: ... def validate_unique(self, exclude: Optional[Collection[str]] = ...) -> None: ... def unique_error_message( - self: _Self, - model_class: Type[_Self], + self, + model_class: Type[Self], unique_check: Collection[Union[Callable[..., Any], str]], ) -> ValidationError: ... def save( diff --git a/django-stubs/db/models/constraints.pyi b/django-stubs/db/models/constraints.pyi index 2bf6bba93..83ea67028 100644 --- a/django-stubs/db/models/constraints.pyi +++ b/django-stubs/db/models/constraints.pyi @@ -1,13 +1,12 @@ from enum import Enum -from typing import Any, Optional, Sequence, Tuple, Type, TypeVar, Union +from typing import Any, Optional, Sequence, Tuple, Type, Union +from typing_extensions import Self from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.models.base import Model from django.db.models.expressions import BaseExpression, Combinable from django.db.models.query_utils import Q -_T = TypeVar("_T", bound="BaseConstraint") - class Deferrable(Enum): DEFERRED: str IMMEDIATE: str @@ -36,7 +35,7 @@ class BaseConstraint: schema_editor: Optional[BaseDatabaseSchemaEditor], ) -> str: ... def deconstruct(self) -> Any: ... - def clone(self: _T) -> _T: ... + def clone(self) -> Self: ... class CheckConstraint(BaseConstraint): check: Q diff --git a/django-stubs/db/models/expressions.pyi b/django-stubs/db/models/expressions.pyi index 4cef8e0a3..aae1119f9 100644 --- a/django-stubs/db/models/expressions.pyi +++ b/django-stubs/db/models/expressions.pyi @@ -12,9 +12,9 @@ from typing import ( Set, Tuple, Type, - TypeVar, Union, ) +from typing_extensions import Self from django.db.models import Q, QuerySet from django.db.models.fields import Field @@ -29,8 +29,6 @@ class SQLiteNumericMixin: self, compiler: SQLCompiler, connection: Any, **extra_context: Any ) -> Tuple[str, List[float]]: ... -_Self = TypeVar("_Self") - _Numeric = Union[float, Decimal] class Combinable: @@ -44,26 +42,22 @@ class Combinable: BITOR: str = ... BITLEFTSHIFT: str = ... BITRIGHTSHIFT: str = ... - def __neg__(self: _Self) -> _Self: ... + def __neg__(self) -> Self: ... def __add__( - self: _Self, other: Optional[Union[timedelta, Combinable, _Numeric, str]] - ) -> _Self: ... - def __sub__( - self: _Self, other: Union[timedelta, Combinable, _Numeric] - ) -> _Self: ... - def __mul__( - self: _Self, other: Union[timedelta, Combinable, _Numeric] - ) -> _Self: ... - def __truediv__(self: _Self, other: Union[Combinable, _Numeric]) -> _Self: ... - def __itruediv__(self: _Self, other: Union[Combinable, _Numeric]) -> _Self: ... - def __mod__(self: _Self, other: Union[int, Combinable]) -> _Self: ... - def __pow__(self: _Self, other: Union[_Numeric, Combinable]) -> _Self: ... - def __and__(self: _Self, other: Combinable) -> _Self: ... - def bitand(self: _Self, other: int) -> _Self: ... - def bitleftshift(self: _Self, other: int) -> _Self: ... - def bitrightshift(self: _Self, other: int) -> _Self: ... - def __or__(self: _Self, other: Combinable) -> _Self: ... - def bitor(self: _Self, other: int) -> _Self: ... + self, other: Optional[Union[timedelta, Combinable, _Numeric, str]] + ) -> Self: ... + def __sub__(self, other: Union[timedelta, Combinable, _Numeric]) -> Self: ... + def __mul__(self, other: Union[timedelta, Combinable, _Numeric]) -> Self: ... + def __truediv__(self, other: Union[Combinable, _Numeric]) -> Self: ... + def __itruediv__(self, other: Union[Combinable, _Numeric]) -> Self: ... + def __mod__(self, other: Union[int, Combinable]) -> Self: ... + def __pow__(self, other: Union[_Numeric, Combinable]) -> Self: ... + def __and__(self, other: Combinable) -> Self: ... + def bitand(self, other: int) -> Self: ... + def bitleftshift(self, other: int) -> Self: ... + def bitrightshift(self, other: int) -> Self: ... + def __or__(self, other: Combinable) -> Self: ... + def bitor(self, other: int) -> Self: ... def __radd__( self, other: Optional[Union[datetime, _Numeric, Combinable]] ) -> Combinable: ... @@ -90,13 +84,13 @@ class BaseExpression: @property def contains_column_references(self) -> bool: ... def resolve_expression( - self: _Self, + self, query: Any = ..., allow_joins: bool = ..., reuse: Optional[Set[str]] = ..., summarize: bool = ..., for_save: bool = ..., - ) -> _Self: ... + ) -> Self: ... @property def field(self) -> Field[Any, Any]: ... @property @@ -107,7 +101,7 @@ class BaseExpression: def get_transform(self, name: str) -> Optional[Type[Expression]]: ... def relabeled_clone(self, change_map: Dict[Optional[str], str]) -> Expression: ... def copy(self) -> BaseExpression: ... - def get_group_by_cols(self: _Self) -> List[_Self]: ... + def get_group_by_cols(self) -> List[Self]: ... def get_source_fields(self) -> List[Optional[Field[Any, Any]]]: ... def asc(self, **kwargs: Any) -> Expression: ... def desc(self, **kwargs: Any) -> Expression: ... @@ -140,13 +134,13 @@ class F(Combinable): name: str def __init__(self, name: str) -> None: ... def resolve_expression( - self: _Self, + self, query: Any = ..., allow_joins: bool = ..., reuse: Optional[Set[str]] = ..., summarize: bool = ..., for_save: bool = ..., - ) -> _Self: ... + ) -> Self: ... def asc(self, **kwargs: Any) -> OrderBy: ... def desc(self, **kwargs: Any) -> OrderBy: ... def deconstruct(self) -> Any: ... diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index 4a85d3d45..ac1a2402f 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -17,6 +17,7 @@ from typing import ( Union, overload, ) +from typing_extensions import Literal, Self from django.core.checks import CheckMessage from django.core.exceptions import FieldDoesNotExist as FieldDoesNotExist @@ -24,7 +25,6 @@ from django.db.models import Model from django.db.models.expressions import Col, Combinable from django.db.models.query_utils import RegisterLookupMixin from django.forms import Widget -from typing_extensions import Literal BLANK_CHOICE_DASH: List[Tuple[str, str]] = ... @@ -35,7 +35,6 @@ _FieldChoices = Iterable[Union[_Choice, _ChoiceNamedGroup]] _ValidatorCallable = Callable[..., None] _ErrorMessagesToOverride = Dict[str, Any] -_T = TypeVar("_T", bound="Field[Any, Any]") # __set__ value type _ST = TypeVar("_ST") # __get__ return type @@ -44,7 +43,6 @@ _GT = TypeVar("_GT") class NOT_PROVIDED: ... class Field(RegisterLookupMixin, Generic[_ST, _GT]): - widget: Widget help_text: str db_table: str @@ -75,13 +73,13 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): def __set__(self, instance: Any, value: _ST) -> None: ... # class access @overload - def __get__(self: _T, instance: None, owner: Any) -> _T: ... + def __get__(self, instance: None, owner: Any) -> Self: ... # Model instance access @overload def __get__(self, instance: Model, owner: Any) -> _GT: ... # non-Model instances @overload - def __get__(self: _T, instance: Any, owner: Any) -> _T: ... + def __get__(self, instance: Any, owner: Any) -> Self: ... def deconstruct(self) -> Any: ... def set_attributes_from_name(self, name: str) -> None: ... def db_type(self, connection: Any) -> str: ... @@ -617,7 +615,7 @@ class AutoField(AutoFieldMixin, IntegerField[int], metaclass=AutoFieldMeta): db_tablespace: Optional[str] = ..., validators: Iterable[_ValidatorCallable] = ..., error_messages: Optional[_ErrorMessagesToOverride] = ..., - ) -> AutoField: ... + ) -> Self: ... class BigAutoField(AutoFieldMixin, BigIntegerField[int]): def __new__( @@ -647,7 +645,7 @@ class BigAutoField(AutoFieldMixin, BigIntegerField[int]): db_tablespace: Optional[str] = ..., validators: Iterable[_ValidatorCallable] = ..., error_messages: Optional[_ErrorMessagesToOverride] = ..., - ) -> BigAutoField: ... + ) -> Self: ... class SmallAutoField(AutoFieldMixin, SmallIntegerField[int]): def __new__( @@ -677,7 +675,7 @@ class SmallAutoField(AutoFieldMixin, SmallIntegerField[int]): db_tablespace: Optional[str] = ..., validators: Iterable[_ValidatorCallable] = ..., error_messages: Optional[_ErrorMessagesToOverride] = ..., - ) -> SmallAutoField: ... + ) -> Self: ... _C = TypeVar("_C", bound=Optional[str]) diff --git a/django-stubs/db/models/fields/files.pyi b/django-stubs/db/models/fields/files.pyi index 3b9e8f368..e7c3c8b1b 100644 --- a/django-stubs/db/models/fields/files.pyi +++ b/django-stubs/db/models/fields/files.pyi @@ -1,14 +1,5 @@ -from typing import ( - Any, - Callable, - Iterable, - Optional, - Tuple, - Type, - TypeVar, - Union, - overload, -) +from typing import Any, Callable, Iterable, Optional, Tuple, Type, Union, overload +from typing_extensions import Self from django.core.files.base import File from django.core.files.images import ImageFile @@ -48,8 +39,6 @@ class FileDescriptor: self, instance: Optional[Model], cls: Type[Model] = ... ) -> Union[FieldFile, FileDescriptor]: ... -_T = TypeVar("_T", bound="Field[Any, Any]") - class FileField(Field[FileDescriptor, FileDescriptor]): storage: Any = ... upload_to: Union[str, Callable[[Any, str], str]] = ... @@ -80,7 +69,7 @@ class FileField(Field[FileDescriptor, FileDescriptor]): db_tablespace: Optional[str] = ..., validators: Iterable[_ValidatorCallable] = ..., error_messages: Optional[_ErrorMessagesToOverride] = ..., - ) -> FileField: ... + ) -> Self: ... # class access @overload # type: ignore def __get__(self, instance: None, owner: Any) -> FileDescriptor: ... @@ -89,7 +78,7 @@ class FileField(Field[FileDescriptor, FileDescriptor]): def __get__(self, instance: Model, owner: Any) -> FieldFile: ... # non-Model instances @overload - def __get__(self: _T, instance: Any, owner: Any) -> _T: ... + def __get__(self, instance: Any, owner: Any) -> Self: ... def generate_filename(self, instance: Optional[Model], filename: str) -> str: ... class ImageFileDescriptor(FileDescriptor): @@ -130,7 +119,7 @@ class ImageField(FileField): db_tablespace: Optional[str] = ..., validators: Iterable[_ValidatorCallable] = ..., error_messages: Optional[_ErrorMessagesToOverride] = ..., - ) -> ImageField: ... + ) -> Self: ... # class access @overload # type: ignore def __get__(self, instance: None, owner: Any) -> ImageFileDescriptor: ... @@ -139,7 +128,7 @@ class ImageField(FileField): def __get__(self, instance: Model, owner: Any) -> ImageFieldFile: ... # non-Model instances @overload - def __get__(self: _T, instance: Any, owner: Any) -> _T: ... + def __get__(self, instance: Any, owner: Any) -> Self: ... def update_dimension_fields( self, instance: Model, force: bool = ..., *args: Any, **kwargs: Any ) -> None: ... diff --git a/django-stubs/db/models/fields/json.pyi b/django-stubs/db/models/fields/json.pyi index b7b3b8259..2b70c7aea 100644 --- a/django-stubs/db/models/fields/json.pyi +++ b/django-stubs/db/models/fields/json.pyi @@ -10,11 +10,11 @@ from typing import ( Union, overload, ) +from typing_extensions import Literal from django.db.models import lookups from django.db.models.expressions import Combinable from django.db.models.lookups import PostgresOperatorLookup, Transform -from typing_extensions import Literal from . import Field, _ErrorMessagesToOverride, _ValidatorCallable from .mixins import CheckFieldDefaultMixin diff --git a/django-stubs/db/models/fields/related.pyi b/django-stubs/db/models/fields/related.pyi index d6fe668a7..7559e5264 100644 --- a/django-stubs/db/models/fields/related.pyi +++ b/django-stubs/db/models/fields/related.pyi @@ -14,6 +14,7 @@ from typing import ( Union, overload, ) +from typing_extensions import Literal, Self from uuid import UUID from django.db import models @@ -44,7 +45,6 @@ from django.db.models.fields.reverse_related import ManyToOneRel as ManyToOneRel from django.db.models.fields.reverse_related import OneToOneRel as OneToOneRel from django.db.models.manager import ManyToManyRelatedManager from django.db.models.query_utils import PathInfo, Q -from typing_extensions import Literal class _DeleteProtocol(Protocol): def __call__( @@ -253,14 +253,10 @@ class ForeignKey(Generic[_M], ForeignObject[_M]): def __get__(self, instance: None, owner: Any) -> ForwardManyToOneDescriptor: ... # Model instance access @overload - def __get__(self: ForeignKey[_M], instance: Any, owner: Any) -> _M: ... - @overload - def __get__( - self: ForeignKey[Optional[_M]], instance: Any, owner: Any - ) -> Optional[_M]: ... + def __get__(self, instance: Model, owner: Any) -> _M: ... # non-Model instances @overload - def __get__(self: _F, instance: Any, owner: Any) -> _F: ... + def __get__(self, instance: Any, owner: Any) -> Self: ... class OneToOneField(Generic[_M], ForeignKey[_M]): one_to_many: Literal[False] = ... @@ -345,14 +341,10 @@ class OneToOneField(Generic[_M], ForeignKey[_M]): def __get__(self, instance: None, owner: Any) -> ForwardOneToOneDescriptor: ... # Model instance access @overload - def __get__(self: OneToOneField[_M], instance: Any, owner: Any) -> _M: ... - @overload - def __get__( - self: OneToOneField[Optional[_M]], instance: Any, owner: Any - ) -> Optional[_M]: ... + def __get__(self, instance: Model, owner: Any) -> _M: ... # non-Model instances @overload - def __get__(self: _F, instance: Any, owner: Any) -> _F: ... + def __get__(self, instance: Any, owner: Any) -> Self: ... _MM = TypeVar("_MM", bound=Model) _MN = TypeVar("_MN", bound=Model) @@ -360,7 +352,6 @@ _MN = TypeVar("_MN", bound=Model) class ManyToManyField( Generic[_MM, _MN], RelatedField[Sequence[_MN], ManyToManyRelatedManager[_MM, _MN]] ): - one_to_many: Literal[False] = ... one_to_one: Literal[False] = ... many_to_many: Literal[True] = ... @@ -405,7 +396,7 @@ class ManyToManyField( db_tablespace: Optional[str] = ..., validators: Iterable[_ValidatorCallable] = ..., error_messages: Optional[_ErrorMessagesToOverride] = ..., - ) -> ManyToManyField[_MM, _MN]: ... + ) -> Self: ... def get_path_info(self, filtered_relation: None = ...) -> List[PathInfo]: ... def get_reverse_path_info( self, filtered_relation: None = ... diff --git a/django-stubs/db/models/lookups.pyi b/django-stubs/db/models/lookups.pyi index 68f0252ec..c543baa14 100644 --- a/django-stubs/db/models/lookups.pyi +++ b/django-stubs/db/models/lookups.pyi @@ -11,6 +11,7 @@ from typing import ( TypeVar, Union, ) +from typing_extensions import Self from django.db.backends.sqlite3.base import DatabaseWrapper from django.db.models.expressions import Expression, Func @@ -57,7 +58,7 @@ class Lookup(Generic[_T]): self, compiler: SQLCompiler, connection: DatabaseWrapper ) -> Tuple[str, List[Union[int, str]]]: ... def rhs_is_direct_value(self) -> bool: ... - def relabeled_clone(self: _T, relabels: Mapping[str, str]) -> _T: ... + def relabeled_clone(self, relabels: Mapping[str, str]) -> Self: ... def get_group_by_cols(self) -> List[Expression]: ... def as_sql(self, compiler: Any, connection: Any) -> Any: ... def contains_aggregate(self) -> bool: ... diff --git a/django-stubs/db/models/manager.pyi b/django-stubs/db/models/manager.pyi index ef40b07a5..49296065f 100644 --- a/django-stubs/db/models/manager.pyi +++ b/django-stubs/db/models/manager.pyi @@ -11,13 +11,13 @@ from typing import ( TypeVar, Union, ) +from typing_extensions import Self from django.db.models.base import Model from django.db.models.query import QuerySet _T = TypeVar("_T", bound=Model) _V = TypeVar("_V", bound=Model) -_M = TypeVar("_M", bound="BaseManager[Any]") class BaseManager(QuerySet[_T]): creation_counter: int = ... @@ -40,8 +40,8 @@ class BaseManager(QuerySet[_T]): def _get_queryset_methods(cls, queryset_class: type) -> Dict[str, Any]: ... def contribute_to_class(self, model: Type[Model], name: str) -> None: ... def db_manager( - self: _M, using: Optional[str] = ..., hints: Optional[Dict[str, Model]] = ... - ) -> _M: ... + self, using: Optional[str] = ..., hints: Optional[Dict[str, Model]] = ... + ) -> Self: ... def get_queryset(self) -> QuerySet[_T]: ... class Manager(BaseManager[_T]): ... diff --git a/django-stubs/db/models/query.pyi b/django-stubs/db/models/query.pyi index f450788f8..82b4b4bb8 100644 --- a/django-stubs/db/models/query.pyi +++ b/django-stubs/db/models/query.pyi @@ -19,6 +19,7 @@ from typing import ( Union, overload, ) +from typing_extensions import Self from django.db import models from django.db.models import Manager @@ -29,7 +30,6 @@ from django.db.models.query_utils import Q as Q # noqa: F401 from django.db.models.sql.query import Query, RawQuery _T = TypeVar("_T", bound=models.Model) -_QS = TypeVar("_QS", bound="_BaseQuerySet[Any]") class _BaseQuerySet(Generic[_T], Sized): model: Type[_T] @@ -48,8 +48,8 @@ class _BaseQuerySet(Generic[_T], Sized): def __class_getitem__(cls, item: Type[_T]) -> Any: ... def __getstate__(self) -> Dict[str, Any]: ... # Technically, the other QuerySet must be of the same type _T, but _T is covariant - def __and__(self: _QS, other: _BaseQuerySet[_T]) -> _QS: ... - def __or__(self: _QS, other: _BaseQuerySet[_T]) -> _QS: ... + def __and__(self, other: _BaseQuerySet[_T]) -> Self: ... + def __or__(self, other: _BaseQuerySet[_T]) -> Self: ... def iterator(self, chunk_size: int = ...) -> Iterator[_T]: ... async def aiterator(self, chunk_size: int = ...) -> Iterator[_T]: ... def aggregate(self, *args: Any, **kwargs: Any) -> Dict[str, Any]: ... @@ -138,29 +138,29 @@ class _BaseQuerySet(Generic[_T], Sized): order: str = ..., tzinfo: Optional[datetime.tzinfo] = ..., ) -> ValuesQuerySet[_T, datetime.datetime]: ... - def none(self: _QS) -> _QS: ... - def all(self: _QS) -> _QS: ... - def filter(self: _QS, *args: Any, **kwargs: Any) -> _QS: ... - def exclude(self: _QS, *args: Any, **kwargs: Any) -> _QS: ... - def complex_filter(self: _QS, filter_obj: Any) -> _QS: ... + def none(self) -> Self: ... + def all(self) -> Self: ... + def filter(self, *args: Any, **kwargs: Any) -> Self: ... + def exclude(self, *args: Any, **kwargs: Any) -> Self: ... + def complex_filter(self, filter_obj: Any) -> Self: ... def count(self) -> int: ... async def acount(self) -> int: ... - def union(self: _QS, *other_qs: Any, all: bool = ...) -> _QS: ... - def intersection(self: _QS, *other_qs: Any) -> _QS: ... - def difference(self: _QS, *other_qs: Any) -> _QS: ... + def union(self, *other_qs: Any, all: bool = ...) -> Self: ... + def intersection(self, *other_qs: Any) -> Self: ... + def difference(self, *other_qs: Any) -> Self: ... def select_for_update( - self: _QS, + self, nowait: bool = ..., skip_locked: bool = ..., of: Sequence[str] = ..., no_key: bool = ..., - ) -> _QS: ... - def select_related(self: _QS, *fields: Any) -> _QS: ... - def prefetch_related(self: _QS, *lookups: Any) -> _QS: ... - def annotate(self: _QS, *args: Any, **kwargs: Any) -> _QS: ... - def alias(self: _QS, *args: Any, **kwargs: Any) -> _QS: ... - def order_by(self: _QS, *field_names: Any) -> _QS: ... - def distinct(self: _QS, *field_names: Any) -> _QS: ... + ) -> Self: ... + def select_related(self, *fields: Any) -> Self: ... + def prefetch_related(self, *lookups: Any) -> Self: ... + def annotate(self, *args: Any, **kwargs: Any) -> Self: ... + def alias(self, *args: Any, **kwargs: Any) -> Self: ... + def order_by(self, *field_names: Any) -> Self: ... + def distinct(self, *field_names: Any) -> Self: ... # extra() return type won't be supported any time soon def extra( self, @@ -171,10 +171,10 @@ class _BaseQuerySet(Generic[_T], Sized): order_by: Optional[Sequence[str]] = ..., select_params: Optional[Sequence[Any]] = ..., ) -> QuerySet[Any]: ... - def reverse(self: _QS) -> _QS: ... - def defer(self: _QS, *fields: Any) -> _QS: ... - def only(self: _QS, *fields: Any) -> _QS: ... - def using(self: _QS, alias: Optional[str]) -> _QS: ... + def reverse(self) -> Self: ... + def defer(self, *fields: Any) -> Self: ... + def only(self, *fields: Any) -> Self: ... + def using(self, alias: Optional[str]) -> Self: ... @property def ordered(self) -> bool: ... @property @@ -188,7 +188,7 @@ class QuerySet(_BaseQuerySet[_T], Collection[_T], Reversible[_T], Sized): @overload def __getitem__(self, i: int) -> _T: ... @overload - def __getitem__(self: _QS, s: slice) -> _QS: ... + def __getitem__(self, s: slice) -> Self: ... def __reversed__(self) -> Iterator[_T]: ... _Row = TypeVar("_Row", covariant=True) @@ -225,7 +225,7 @@ class ValuesQuerySet(_BaseQuerySet[_T], Collection[_Row], Sized): @overload def __getitem__(self, i: int) -> _Row: ... @overload - def __getitem__(self: _QS, s: slice) -> _QS: ... + def __getitem__(self, s: slice) -> Self: ... def iterator(self, chunk_size: int = ...) -> Iterator[_Row]: ... # type: ignore async def aiterator(self, chunk_size: int = ...) -> Iterator[_Row]: ... # type: ignore def get(self, *args: Any, **kwargs: Any) -> _Row: ... # type: ignore diff --git a/django-stubs/forms/models.pyi b/django-stubs/forms/models.pyi index 6c31e4a25..9d6f8e977 100644 --- a/django-stubs/forms/models.pyi +++ b/django-stubs/forms/models.pyi @@ -16,6 +16,7 @@ from typing import ( TypeVar, Union, ) +from typing_extensions import Literal from unittest.mock import MagicMock from uuid import UUID @@ -31,7 +32,6 @@ from django.forms.forms import BaseForm, DeclarativeFieldsMetaclass from django.forms.formsets import BaseFormSet from django.forms.utils import ErrorList from django.forms.widgets import Input, Widget -from typing_extensions import Literal ALL_FIELDS: str diff --git a/django-stubs/http/request.pyi b/django-stubs/http/request.pyi index 0950561c0..c86a0f616 100644 --- a/django-stubs/http/request.pyi +++ b/django-stubs/http/request.pyi @@ -10,11 +10,10 @@ from typing import ( Pattern, Set, Tuple, - Type, - TypeVar, Union, overload, ) +from typing_extensions import Self from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.models import AnonymousUser @@ -90,8 +89,6 @@ class HttpRequest(BytesIO): def body(self) -> bytes: ... def _load_post_and_files(self) -> None: ... -_Q = TypeVar("_Q", bound="QueryDict") - class QueryDict(MultiValueDict[str, str]): encoding: str = ... _mutable: bool = ... @@ -109,12 +106,12 @@ class QueryDict(MultiValueDict[str, str]): def urlencode(self, safe: Optional[str] = ...) -> str: ... @classmethod def fromkeys( - cls: Type[_Q], + cls, iterable: Iterable[Union[bytes, str]], value: Any = ..., mutable: bool = ..., encoding: Optional[str] = ..., - ) -> _Q: ... + ) -> Self: ... @overload def bytes_to_text(s: bytes, encoding: str) -> str: ... diff --git a/django-stubs/shortcuts.pyi b/django-stubs/shortcuts.pyi index b4c042746..ee29ce4d0 100644 --- a/django-stubs/shortcuts.pyi +++ b/django-stubs/shortcuts.pyi @@ -1,4 +1,3 @@ -import sys from typing import ( Any, Callable, @@ -12,6 +11,7 @@ from typing import ( Union, overload, ) +from typing_extensions import Literal from django.db.models import Manager, QuerySet from django.db.models.base import Model @@ -22,11 +22,6 @@ from django.http.response import ( ) from django.http.response import HttpResponseRedirect as HttpResponseRedirect -if sys.version_info < (3, 8): - from typing_extensions import Literal -else: - from typing import Literal - def render_to_response( template_name: Union[str, Sequence[str]], context: Optional[Mapping[str, Any]] = ..., diff --git a/django-stubs/test/html.pyi b/django-stubs/test/html.pyi index 35f5f8ea2..6f4710d4d 100644 --- a/django-stubs/test/html.pyi +++ b/django-stubs/test/html.pyi @@ -1,7 +1,5 @@ from html.parser import HTMLParser -from typing import Any, List, Optional, Sequence, Tuple, TypeVar, Union - -_Self = TypeVar("_Self") +from typing import Any, List, Optional, Sequence, Tuple, Union WHITESPACE: Any diff --git a/django-stubs/utils/datastructures.pyi b/django-stubs/utils/datastructures.pyi index a7ea38375..5ca577487 100644 --- a/django-stubs/utils/datastructures.pyi +++ b/django-stubs/utils/datastructures.pyi @@ -14,8 +14,7 @@ from typing import ( Union, overload, ) - -from typing_extensions import Literal +from typing_extensions import Literal, Self _K = TypeVar("_K") _V = TypeVar("_V") @@ -34,8 +33,6 @@ class OrderedSet(MutableSet[_K]): class MultiValueDictKeyError(KeyError): ... -_D = TypeVar("_D", bound="MultiValueDict[Any, Any]") - class MultiValueDict(MutableMapping[_K, _V]): @overload def __init__( @@ -60,7 +57,7 @@ class MultiValueDict(MutableMapping[_K, _V]): def appendlist(self, key: _K, value: _V) -> None: ... def lists(self) -> Iterable[Tuple[_K, List[_V]]]: ... def dict(self) -> Dict[_K, Union[_V, List[_V]]]: ... - def copy(self: _D) -> _D: ... + def copy(self) -> Self: ... # These overrides are needed to convince mypy that this isn't an abstract class def __delitem__(self, item: _K) -> None: ... def __getitem__(self, item: _K) -> Union[_V, Literal[[]]]: ... # type: ignore @@ -71,9 +68,7 @@ class MultiValueDict(MutableMapping[_K, _V]): class ImmutableList(Tuple[_V, ...]): warning: str = ... def __init__(self, *args: Any, warning: str = ..., **kwargs: Any) -> None: ... - def __new__( - cls, *args: Any, warning: str = ..., **kwargs: Any - ) -> ImmutableList[_V]: ... + def __new__(cls, *args: Any, warning: str = ..., **kwargs: Any) -> Self: ... def complain(self, *wargs: Any, **kwargs: Any) -> None: ... class DictWrapper(Dict[str, _V]): @@ -88,11 +83,9 @@ class DictWrapper(Dict[str, _V]): self, data: Iterable[Tuple[str, _V]], func: Callable[[_V], _V], prefix: str ) -> None: ... -_T = TypeVar("_T", bound="CaseInsensitiveMapping[Any, Any]") - class CaseInsensitiveMapping(Mapping[_K, _V]): def __init__(self, data: Any) -> None: ... def __getitem__(self, key: _K) -> Any: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[_K]: ... - def copy(self: _T) -> _T: ... + def copy(self) -> Self: ... diff --git a/django-stubs/utils/functional.pyi b/django-stubs/utils/functional.pyi index 8e4b282bb..d5966474a 100644 --- a/django-stubs/utils/functional.pyi +++ b/django-stubs/utils/functional.pyi @@ -12,6 +12,7 @@ from typing import ( Union, overload, ) +from typing_extensions import Self from django.db.models.base import Model @@ -25,9 +26,7 @@ class cached_property(Generic[_T]): name: str = ... def __init__(self, func: Callable[..., _T], name: Optional[str] = ...) -> None: ... @overload - def __get__( - self, instance: None, cls: Type[Any] = ... - ) -> "cached_property[_T]": ... + def __get__(self, instance: None, cls: Type[Any] = ...) -> Self: ... @overload def __get__(self, instance: object, cls: Type[Any] = ...) -> _T: ... diff --git a/django-stubs/utils/safestring.pyi b/django-stubs/utils/safestring.pyi index 44809642d..18d7aa265 100644 --- a/django-stubs/utils/safestring.pyi +++ b/django-stubs/utils/safestring.pyi @@ -1,9 +1,8 @@ -from typing import Any, TypeVar, overload - -_SD = TypeVar("_SD", bound="SafeData") +from typing import Any, overload +from typing_extensions import Self class SafeData: - def __html__(self: _SD) -> _SD: ... + def __html__(self) -> Self: ... class SafeText(str, SafeData): @overload diff --git a/django-stubs/views/generic/base.pyi b/django-stubs/views/generic/base.pyi index 66b0706c9..bc0f49c6f 100644 --- a/django-stubs/views/generic/base.pyi +++ b/django-stubs/views/generic/base.pyi @@ -12,7 +12,7 @@ class View: kwargs: Any = ... def __init__(self, **kwargs: Any) -> None: ... @classmethod - def as_view(cls: Any, **initkwargs: Any) -> Callable[..., http.HttpResponse]: ... + def as_view(cls, **initkwargs: Any) -> Callable[..., http.HttpResponse]: ... def setup(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> None: ... def dispatch( self, request: http.HttpRequest, *args: Any, **kwargs: Any diff --git a/django-stubs/views/generic/edit.pyi b/django-stubs/views/generic/edit.pyi index 2924d2beb..2ab2a9fa6 100644 --- a/django-stubs/views/generic/edit.pyi +++ b/django-stubs/views/generic/edit.pyi @@ -9,6 +9,7 @@ from typing import ( TypeVar, Union, ) +from typing_extensions import Literal from django.forms.forms import BaseForm from django.forms.models import BaseModelForm @@ -19,7 +20,6 @@ from django.views.generic.detail import ( SingleObjectMixin, SingleObjectTemplateResponseMixin, ) -from typing_extensions import Literal _FormT = TypeVar("_FormT", bound=BaseForm) diff --git a/psycopg2-stubs/extensions.pyi b/psycopg2-stubs/extensions.pyi index f2cb77c4e..22328e384 100644 --- a/psycopg2-stubs/extensions.pyi +++ b/psycopg2-stubs/extensions.pyi @@ -16,9 +16,8 @@ from typing import ( Tuple, Union, ) -from uuid import UUID - from typing_extensions import Literal +from uuid import UUID ISOLATION_LEVEL_AUTOCOMMIT: Literal[0] ISOLATION_LEVEL_READ_UNCOMMITTED: Literal[4] diff --git a/psycopg2-stubs/extras.pyi b/psycopg2-stubs/extras.pyi index 575418216..3d529eff3 100644 --- a/psycopg2-stubs/extras.pyi +++ b/psycopg2-stubs/extras.pyi @@ -13,6 +13,7 @@ from typing import ( Union, overload, ) +from typing_extensions import Literal, Protocol from psycopg2._psycopg import ReplicationConnection as _replicationConnection from psycopg2._psycopg import ReplicationCursor as _replicationCursor @@ -23,7 +24,6 @@ from psycopg2._range import Range as Range from psycopg2.extensions import _SQLType from psycopg2.extensions import connection as _connection from psycopg2.extensions import cursor as _cursor -from typing_extensions import Literal, Protocol class DictCursorBase(_cursor): _query_executed: bool diff --git a/pyproject.toml b/pyproject.toml index 8b389136b..357d49929 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,10 @@ include = '\.pyi?$' [tool.isort] profile = "black" +extra_standard_library = [ + "typing_extensions", + "_typeshed", +] [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/tests/pyright/base.py b/tests/pyright/base.py index 8afc7e53a..144dbd719 100644 --- a/tests/pyright/base.py +++ b/tests/pyright/base.py @@ -5,7 +5,6 @@ import tempfile from dataclasses import dataclass from typing import List, cast - from typing_extensions import Literal _cwd = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))