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

Use typing_extensions.Self in the stubs/ directory #9702

Merged
merged 8 commits into from
Feb 15, 2023
Merged
6 changes: 3 additions & 3 deletions stubs/DateTimeRange/datetimerange/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
from _typeshed import Self
from collections.abc import Iterable
from typing import ClassVar
from typing_extensions import Self

from dateutil.relativedelta import relativedelta

Expand Down Expand Up @@ -33,9 +33,9 @@ class DateTimeRange:
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...
def __add__(self, other: datetime.timedelta) -> DateTimeRange: ...
def __iadd__(self: Self, other: datetime.timedelta) -> Self: ...
def __iadd__(self, other: datetime.timedelta) -> Self: ...
def __sub__(self, other: datetime.timedelta) -> DateTimeRange: ...
def __isub__(self: Self, other: datetime.timedelta) -> Self: ...
def __isub__(self, other: datetime.timedelta) -> Self: ...
def __contains__(self, x: datetime.timedelta | datetime.datetime | DateTimeRange | str) -> bool: ...
@property
def start_datetime(self) -> datetime.datetime: ...
Expand Down
4 changes: 2 additions & 2 deletions stubs/ExifRead/exifread/utils.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from _typeshed import Self
from collections.abc import Mapping
from fractions import Fraction
from typing import Any, TypeVar, overload
from typing_extensions import Self

_T = TypeVar("_T")

Expand All @@ -14,7 +14,7 @@ def make_string_uc(seq: str | list[int]) -> str: ...
def get_gps_coords(tags: Mapping[str, Any]) -> tuple[float, float]: ...

class Ratio(Fraction):
def __new__(cls: type[Self], numerator: int = ..., denominator: int | None = ...) -> Self: ...
def __new__(cls, numerator: int = ..., denominator: int | None = ...) -> Self: ...
@property
def num(self) -> int: ...
@property
Expand Down
5 changes: 2 additions & 3 deletions stubs/JACK-Client/jack/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import sys
from _typeshed import Self
from collections.abc import Callable, Generator, Iterable, Iterator, Sequence
from typing import Any, NoReturn, overload
from typing_extensions import Literal
from typing_extensions import Literal, Self

import numpy
from _cffi_backend import _CDataBase
Expand Down Expand Up @@ -80,7 +79,7 @@ class Client:
servername: str | None = ...,
session_id: str | None = ...,
) -> None: ...
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(self, *args: object) -> None: ...
@property
def name(self) -> str: ...
Expand Down
5 changes: 2 additions & 3 deletions stubs/Markdown/markdown/core.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from _typeshed import Self
from collections.abc import Callable, Mapping, Sequence
from typing import Any, ClassVar, Protocol
from typing_extensions import Literal
from typing_extensions import Literal, Self
from xml.etree.ElementTree import Element

from .blockparser import BlockParser
Expand Down Expand Up @@ -45,7 +44,7 @@ class Markdown:
def registerExtensions(self, extensions: Sequence[Extension | str], configs: Mapping[str, Mapping[str, Any]]) -> Markdown: ...
def build_extension(self, ext_name: str, configs: Mapping[str, str]) -> Extension: ...
def registerExtension(self, extension: Extension) -> Markdown: ...
def reset(self: Self) -> Self: ...
def reset(self) -> Self: ...
def set_output_format(self, format: Literal["xhtml", "html"]) -> Markdown: ...
def is_block_level(self, tag: str) -> bool: ...
def convert(self, source: str) -> str: ...
Expand Down
6 changes: 3 additions & 3 deletions stubs/Pillow/PIL/Image.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from _typeshed import Incomplete, Self, SupportsRead, SupportsWrite
from _typeshed import Incomplete, SupportsRead, SupportsWrite
from collections.abc import Callable, Iterable, Iterator, MutableMapping, Sequence
from enum import IntEnum
from pathlib import Path
from typing import Any, ClassVar, Protocol, SupportsBytes
from typing_extensions import Literal, TypeAlias
from typing_extensions import Literal, Self, TypeAlias

from PIL.PyAccess import PyAccess

Expand Down Expand Up @@ -171,7 +171,7 @@ class Image:
def height(self) -> int: ...
@property
def size(self) -> tuple[int, int]: ...
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(self, *args: object) -> None: ...
def close(self) -> None: ...
def __eq__(self, other: object) -> bool: ...
Expand Down
5 changes: 3 additions & 2 deletions stubs/Pillow/PIL/ImageFile.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from typing import Any, NoReturn
from typing_extensions import Self

from .Image import Image

Expand Down Expand Up @@ -40,7 +41,7 @@ class Parser:
def reset(self) -> None: ...
decode: Any
def feed(self, data) -> None: ...
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(self, *args: object) -> None: ...
def close(self) -> Image: ...

Expand Down
8 changes: 4 additions & 4 deletions stubs/Pillow/PIL/ImageFilter.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from collections.abc import Callable, Iterable, Sequence
from typing import Any
from typing_extensions import Literal, TypeAlias
from typing_extensions import Literal, Self, TypeAlias

from .Image import Image

Expand Down Expand Up @@ -122,14 +122,14 @@ class Color3DLUT(MultibandFilter):
) -> None: ...
@classmethod
def generate(
cls: type[Self],
cls,
size: int | tuple[int, int, int],
callback: Callable[[float, float, float], Iterable[float]],
channels: int = ...,
target_mode: str | None = ...,
) -> Self: ...
def transform(
self: Self,
self,
callback: Callable[..., Iterable[float]],
with_normals: bool = ...,
channels: Literal[3, 4] | None = ...,
Expand Down
5 changes: 3 additions & 2 deletions stubs/PyMySQL/pymysql/connections.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from collections.abc import Mapping
from socket import socket as _socket
from typing import Any, AnyStr, Generic, TypeVar, overload
from typing_extensions import Self

from .charset import charset_by_id as charset_by_id, charset_by_name as charset_by_name
from .constants import CLIENT as CLIENT, COMMAND as COMMAND, FIELD_TYPE as FIELD_TYPE, SERVER_STATUS as SERVER_STATUS
Expand Down Expand Up @@ -197,7 +198,7 @@ class Connection(Generic[_C]):
def get_proto_info(self): ...
def get_server_info(self): ...
def show_warnings(self): ...
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(self, *exc_info: object) -> None: ...
Warning: Any
Error: Any
Expand Down
4 changes: 2 additions & 2 deletions stubs/PyMySQL/pymysql/cursors.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from _typeshed import Self
from collections.abc import Iterable, Iterator
from typing import Any
from typing_extensions import Self

from .connections import Connection

Expand All @@ -24,7 +24,7 @@ class Cursor:
def executemany(self, query: str, args: Iterable[object]) -> int | None: ...
def callproc(self, procname: str, args: Iterable[Any] = ...) -> Any: ...
def scroll(self, value: int, mode: str = ...) -> None: ...
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(self, *exc_info: object) -> None: ...
# Methods returning result tuples are below.
def fetchone(self) -> tuple[Any, ...] | None: ...
Expand Down
6 changes: 3 additions & 3 deletions stubs/Pygments/pygments/token.pyi
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from _typeshed import Self
from collections.abc import Mapping
from typing import Any
from typing_extensions import Self

class _TokenType(tuple[str, ...]):
parent: _TokenType | None
def split(self) -> list[_TokenType]: ...
subtypes: set[_TokenType]
def __contains__(self, val: _TokenType) -> bool: ... # type: ignore[override]
def __getattr__(self, name: str) -> _TokenType: ...
def __copy__(self: Self) -> Self: ...
def __deepcopy__(self: Self, memo: Any) -> Self: ...
def __copy__(self) -> Self: ...
def __deepcopy__(self, memo: Any) -> Self: ...

Token: _TokenType
Text: _TokenType
Expand Down
6 changes: 3 additions & 3 deletions stubs/SQLAlchemy/sqlalchemy/engine/base.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from _typeshed.dbapi import DBAPIConnection
from abc import abstractmethod
from collections.abc import Callable, Mapping
from types import TracebackType
from typing import Any, TypeVar, overload
from typing_extensions import Concatenate, ParamSpec, TypeAlias
from typing_extensions import Concatenate, ParamSpec, Self, TypeAlias

from ..log import Identified, _EchoFlag, echo_property
from ..pool import Pool
Expand Down Expand Up @@ -40,7 +40,7 @@ class Connection(Connectable):
_allow_revalidate: bool = ...,
) -> None: ...
def schema_for_object(self, obj) -> str | None: ...
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(
self, type_: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...
Expand Down
4 changes: 2 additions & 2 deletions stubs/SQLAlchemy/sqlalchemy/engine/mock.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from _typeshed import Self
from abc import abstractmethod
from collections.abc import Mapping
from typing import Any, overload
from typing_extensions import Self

from .base import _Executable
from .cursor import CursorResult
Expand All @@ -11,7 +11,7 @@ from .url import URL
class MockConnection(Connectable):
def __init__(self, dialect: Dialect, execute) -> None: ...
@property
def engine(self: Self) -> Self: ... # type: ignore[override]
def engine(self) -> Self: ... # type: ignore[override]
@property
def dialect(self) -> Dialect: ...
@property
Expand Down
7 changes: 4 additions & 3 deletions stubs/SQLAlchemy/sqlalchemy/engine/result.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from collections.abc import Generator, KeysView
from typing import Any
from typing_extensions import Self

from ..sql.base import InPlaceGenerative
from .row import Row
Expand Down Expand Up @@ -38,8 +39,8 @@ class _WithKeys:
class Result(_WithKeys, ResultInternal):
def __init__(self, cursor_metadata) -> None: ...
def close(self) -> None: ...
def yield_per(self: Self, num: int) -> Self: ...
def unique(self: Self, strategy: Incomplete | None = ...) -> Self: ...
def yield_per(self, num: int) -> Self: ...
def unique(self, strategy: Incomplete | None = ...) -> Self: ...
def columns(self, *col_expressions): ...
def scalars(self, index: int = ...) -> ScalarResult: ...
def mappings(self) -> MappingResult: ...
Expand Down
16 changes: 8 additions & 8 deletions stubs/SQLAlchemy/sqlalchemy/engine/url.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from _typeshed import Self, SupportsItems
from _typeshed import SupportsItems
from collections.abc import Iterable, Mapping, Sequence
from typing import Any, NamedTuple
from typing_extensions import TypeAlias
from typing_extensions import Self, TypeAlias

from ..util import immutabledict
from .interfaces import Dialect
Expand Down Expand Up @@ -31,7 +31,7 @@ class URL(_URLTuple):
query: _Query | None = ...,
) -> URL: ...
def set(
self: Self,
self,
drivername: str | None = ...,
username: str | None = ...,
password: str | object | None = ...,
Expand All @@ -40,16 +40,16 @@ class URL(_URLTuple):
database: str | None = ...,
query: _Query | None = ...,
) -> Self: ...
def update_query_string(self: Self, query_string: str, append: bool = ...) -> Self: ...
def update_query_pairs(self: Self, key_value_pairs: Iterable[tuple[str, str]], append: bool = ...) -> Self: ...
def update_query_dict(self: Self, query_parameters: SupportsItems[str, str | Sequence[str]], append: bool = ...) -> Self: ...
def update_query_string(self, query_string: str, append: bool = ...) -> Self: ...
def update_query_pairs(self, key_value_pairs: Iterable[tuple[str, str]], append: bool = ...) -> Self: ...
def update_query_dict(self, query_parameters: SupportsItems[str, str | Sequence[str]], append: bool = ...) -> Self: ...
def difference_update_query(self, names: Iterable[str]) -> URL: ...
@property
def normalized_query(self) -> immutabledict[str, tuple[str, ...]]: ...
def __to_string__(self, hide_password: bool = ...) -> str: ...
def render_as_string(self, hide_password: bool = ...) -> str: ...
def __copy__(self: Self) -> Self: ...
def __deepcopy__(self: Self, memo: object) -> Self: ...
def __copy__(self) -> Self: ...
def __deepcopy__(self, memo: object) -> Self: ...
def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...
Expand Down
4 changes: 2 additions & 2 deletions stubs/SQLAlchemy/sqlalchemy/engine/util.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from _typeshed import Self
from collections.abc import Callable
from types import TracebackType
from typing import Any
from typing_extensions import Self

def connection_memoize(key: str) -> Callable[..., Any]: ...

class TransactionalContext:
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(
self, type_: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...
5 changes: 3 additions & 2 deletions stubs/SQLAlchemy/sqlalchemy/ext/asyncio/session.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from typing import Any
from typing_extensions import Self

from ...util import memoized_property
from .base import ReversibleProxy, StartableContext
Expand Down Expand Up @@ -53,7 +54,7 @@ class AsyncSession(ReversibleProxy):
async def close(self): ...
@classmethod
async def close_all(cls): ...
async def __aenter__(self: Self) -> Self: ...
async def __aenter__(self) -> Self: ...
async def __aexit__(self, type_, value, traceback) -> None: ...
# proxied from Session
identity_map: Any
Expand Down
5 changes: 2 additions & 3 deletions stubs/SQLAlchemy/sqlalchemy/log.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from _typeshed import Self
from logging import Logger
from typing import Any, TypeVar, overload
from typing_extensions import Literal, TypeAlias
from typing_extensions import Literal, Self, TypeAlias

_ClsT = TypeVar("_ClsT", bound=type)
_EchoFlag: TypeAlias = bool | Literal["debug"] | None
Expand Down Expand Up @@ -33,7 +32,7 @@ def instance_logger(instance: Identified, echoflag: _EchoFlag = ...) -> None: ..
class echo_property:
__doc__: str
@overload
def __get__(self: Self, instance: None, owner: object) -> Self: ...
def __get__(self, instance: None, owner: object) -> Self: ...
@overload
def __get__(self, instance: Identified, owner: object) -> _EchoFlag: ...
def __set__(self, instance: Identified, value: _EchoFlag) -> None: ...