Use typing_extensions.Self instead of _typeshed.Self (#9702)

This commit is contained in:
Alex Waygood
2023-02-15 11:32:43 +01:00
committed by GitHub
parent 8cd6d81f15
commit 7180d0223b
140 changed files with 597 additions and 610 deletions
+2 -3
View File
@@ -1,10 +1,9 @@
import queue
from _typeshed import Self
from collections.abc import Mapping
from logging import Logger
from types import TracebackType
from typing import Any, ClassVar
from typing_extensions import Literal, TypeAlias
from typing_extensions import Literal, Self, TypeAlias
from . import connection, exceptions, request, response
from .connection import BaseSSLError as BaseSSLError, ConnectionError as ConnectionError, HTTPException as HTTPException
@@ -47,7 +46,7 @@ class ConnectionPool:
host: str
port: int | None
def __init__(self, host: str, port: int | None = ...) -> None: ...
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> Literal[False]: ...
+2 -3
View File
@@ -1,9 +1,8 @@
import io
from _typeshed import Self
from collections.abc import Iterable, Iterator, Mapping
from http.client import HTTPMessage as _HttplibHTTPMessage, HTTPResponse as _HttplibHTTPResponse
from typing import IO, Any
from typing_extensions import Literal, TypeAlias
from typing_extensions import Literal, Self, TypeAlias
from urllib3.connectionpool import HTTPConnection
@@ -83,7 +82,7 @@ class HTTPResponse(io.IOBase):
def read(self, amt: int | None = ..., decode_content: bool | None = ..., cache_content: bool = ...) -> bytes: ...
def stream(self, amt: int | None = ..., decode_content: bool | None = ...) -> Iterator[bytes]: ...
@classmethod
def from_httplib(cls: type[Self], r: _HttplibHTTPResponse, **response_kw: Any) -> Self: ...
def from_httplib(cls, r: _HttplibHTTPResponse, **response_kw: Any) -> Self: ...
def getheaders(self) -> HTTPHeaderDict: ...
def getheader(self, name, default=...) -> str | None: ...
def info(self) -> HTTPHeaderDict: ...
+2 -3
View File
@@ -1,9 +1,8 @@
import logging
from _typeshed import Self
from collections.abc import Collection
from types import TracebackType
from typing import Any, ClassVar, NamedTuple
from typing_extensions import Literal
from typing_extensions import Literal, Self
from .. import exceptions
from ..connectionpool import ConnectionPool
@@ -62,7 +61,7 @@ class Retry:
remove_headers_on_redirect: Collection[str] = ...,
method_whitelist: Collection[str] | None = ...,
) -> None: ...
def new(self: Self, **kw: Any) -> Self: ...
def new(self, **kw: Any) -> Self: ...
@classmethod
def from_int(
cls, retries: Retry | bool | int | None, redirect: bool | int | None = ..., default: Retry | bool | int | None = ...