From 369e761483b2635695b3009a6ffb0580c637809e Mon Sep 17 00:00:00 2001 From: jpy-git Date: Sat, 8 Jan 2022 19:14:39 +0000 Subject: [PATCH 01/10] Update urllib3.exceptions stubs --- stubs/urllib3/@tests/stubtest_allowlist.txt | 2 - stubs/urllib3/urllib3/exceptions.pyi | 69 ++++++++++++++++----- 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/stubs/urllib3/@tests/stubtest_allowlist.txt b/stubs/urllib3/@tests/stubtest_allowlist.txt index c1ad59f1549d..a2e2b308397e 100644 --- a/stubs/urllib3/@tests/stubtest_allowlist.txt +++ b/stubs/urllib3/@tests/stubtest_allowlist.txt @@ -25,13 +25,11 @@ urllib3.connectionpool.HTTPConnectionPool.urlopen urllib3.connectionpool.HTTPResponse.__init__ urllib3.connectionpool.HTTPSConnection.__init__ urllib3.connectionpool.HTTPSConnectionPool.__init__ -urllib3.connectionpool.ProxyError.__init__ urllib3.connectionpool.RequestMethods.request_encode_url urllib3.connectionpool.Retry.is_forced_retry urllib3.connectionpool.Retry.sleep urllib3.connectionpool.VerifiedHTTPSConnection.__init__ urllib3.connectionpool.VerifiedHTTPSConnection.set_cert -urllib3.exceptions.ProxyError.__init__ urllib3.fields.RequestField.__init__ urllib3.fields.RequestField.from_tuples urllib3.filepost.RequestField.__init__ diff --git a/stubs/urllib3/urllib3/exceptions.pyi b/stubs/urllib3/urllib3/exceptions.pyi index ddb4e83ba77e..9c3b5c03a4a2 100644 --- a/stubs/urllib3/urllib3/exceptions.pyi +++ b/stubs/urllib3/urllib3/exceptions.pyi @@ -1,50 +1,87 @@ +from email.errors import MessageDefect +from http.client import IncompleteRead as httplib_IncompleteRead from typing import Any +from urllib3.connectionpool import ConnectionPool, HTTPResponse +from urllib3.util.retry import Retry + class HTTPError(Exception): ... class HTTPWarning(Warning): ... class PoolError(HTTPError): - pool: Any - def __init__(self, pool, message) -> None: ... - def __reduce__(self): ... + def __init__(self, pool: ConnectionPool, message: str) -> None: ... + def __reduce__(self) -> tuple[Any, tuple[Any, ...]]: ... class RequestError(PoolError): - url: Any - def __init__(self, pool, url, message) -> None: ... - def __reduce__(self): ... + def __init__(self, pool: ConnectionPool, url: str, message: str) -> None: ... + def __reduce__(self) -> tuple[Any, tuple[Any, ...]]: ... class SSLError(HTTPError): ... -class ProxyError(HTTPError): ... + +class ProxyError(HTTPError): + original_error: Exception + def __init__(self, message: str, error: Exception, *args: Any) -> None: ... + class DecodeError(HTTPError): ... class ProtocolError(HTTPError): ... -ConnectionError: Any +ConnectionError = ProtocolError class MaxRetryError(RequestError): - reason: Any - def __init__(self, pool, url, reason=...) -> None: ... + reason: Exception | Any + def __init__(self, pool: ConnectionPool, url: str, reason: Exception | None = ...) -> None: ... class HostChangedError(RequestError): - retries: Any - def __init__(self, pool, url, retries=...) -> None: ... + retries: Retry | int + def __init__(self, pool: ConnectionPool, url: str, retries: Retry | int = ...) -> None: ... class TimeoutStateError(HTTPError): ... class TimeoutError(HTTPError): ... class ReadTimeoutError(TimeoutError, RequestError): ... class ConnectTimeoutError(TimeoutError): ... +class NewConnectionError(ConnectTimeoutError, HTTPError): ... class EmptyPoolError(PoolError): ... class ClosedPoolError(PoolError): ... class LocationValueError(ValueError, HTTPError): ... class LocationParseError(LocationValueError): - location: Any - def __init__(self, location) -> None: ... + def __init__(self, location: str) -> None: ... + +class URLSchemeUnknown(LocationValueError): + def __init__(self, scheme: str) -> None: ... class ResponseError(HTTPError): - GENERIC_ERROR: Any - SPECIFIC_ERROR: Any + GENERIC_ERROR: str + SPECIFIC_ERROR: str class SecurityWarning(HTTPWarning): ... +class SubjectAltNameWarning(SecurityWarning): ... class InsecureRequestWarning(SecurityWarning): ... class SystemTimeWarning(SecurityWarning): ... class InsecurePlatformWarning(SecurityWarning): ... +class SNIMissingWarning(HTTPWarning): ... +class DependencyWarning(HTTPWarning): ... +class ResponseNotChunked(ProtocolError, ValueError): ... +class BodyNotHttplibCompatible(HTTPError): ... + +class IncompleteRead(HTTPError, httplib_IncompleteRead): + def __init__(self, partial: bytes, expected: int | None) -> None: ... + def __repr__(self) -> str: ... + +class InvalidChunkLength(HTTPError, httplib_IncompleteRead): + response: HTTPResponse + length: bytes + def __init__(self, response: HTTPResponse, length: bytes) -> None: ... + def __repr__(self) -> str: ... + +class InvalidHeader(HTTPError): ... + +class ProxySchemeUnknown(AssertionError, URLSchemeUnknown): + def __init__(self, scheme: str | None) -> None: ... + +class ProxySchemeUnsupported(ValueError): ... + +class HeaderParsingError(HTTPError): + def __init__(self, defects: list[MessageDefect], unparsed_data: str | bytes | None) -> None: ... + +class UnrewindableBodyError(HTTPError): ... From 300ffdd5477a1da4d3bd0a4ece73f947da578fca Mon Sep 17 00:00:00 2001 From: Joseph Young <80432516+jpy-git@users.noreply.github.com> Date: Sat, 8 Jan 2022 19:36:31 +0000 Subject: [PATCH 02/10] Update stubs/urllib3/urllib3/exceptions.pyi Co-authored-by: Sebastian Rittau --- stubs/urllib3/urllib3/exceptions.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stubs/urllib3/urllib3/exceptions.pyi b/stubs/urllib3/urllib3/exceptions.pyi index 9c3b5c03a4a2..c3a74d13bc66 100644 --- a/stubs/urllib3/urllib3/exceptions.pyi +++ b/stubs/urllib3/urllib3/exceptions.pyi @@ -9,6 +9,7 @@ class HTTPError(Exception): ... class HTTPWarning(Warning): ... class PoolError(HTTPError): + pool: ConnectionPool def __init__(self, pool: ConnectionPool, message: str) -> None: ... def __reduce__(self) -> tuple[Any, tuple[Any, ...]]: ... From f0a268fda067b04a0da818290e6651d44cf6421f Mon Sep 17 00:00:00 2001 From: Joseph Young <80432516+jpy-git@users.noreply.github.com> Date: Sat, 8 Jan 2022 19:36:44 +0000 Subject: [PATCH 03/10] Update stubs/urllib3/urllib3/exceptions.pyi Co-authored-by: Sebastian Rittau --- stubs/urllib3/urllib3/exceptions.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stubs/urllib3/urllib3/exceptions.pyi b/stubs/urllib3/urllib3/exceptions.pyi index c3a74d13bc66..2c022dfac17b 100644 --- a/stubs/urllib3/urllib3/exceptions.pyi +++ b/stubs/urllib3/urllib3/exceptions.pyi @@ -14,6 +14,7 @@ class PoolError(HTTPError): def __reduce__(self) -> tuple[Any, tuple[Any, ...]]: ... class RequestError(PoolError): + url: str def __init__(self, pool: ConnectionPool, url: str, message: str) -> None: ... def __reduce__(self) -> tuple[Any, tuple[Any, ...]]: ... From 4bec3ee1fede379c6618d52f2d687c6f79cc0dcb Mon Sep 17 00:00:00 2001 From: Joseph Young <80432516+jpy-git@users.noreply.github.com> Date: Sat, 8 Jan 2022 19:36:57 +0000 Subject: [PATCH 04/10] Update stubs/urllib3/urllib3/exceptions.pyi Co-authored-by: Sebastian Rittau --- stubs/urllib3/urllib3/exceptions.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stubs/urllib3/urllib3/exceptions.pyi b/stubs/urllib3/urllib3/exceptions.pyi index 2c022dfac17b..4ba24a9e741a 100644 --- a/stubs/urllib3/urllib3/exceptions.pyi +++ b/stubs/urllib3/urllib3/exceptions.pyi @@ -47,6 +47,7 @@ class ClosedPoolError(PoolError): ... class LocationValueError(ValueError, HTTPError): ... class LocationParseError(LocationValueError): + location: str def __init__(self, location: str) -> None: ... class URLSchemeUnknown(LocationValueError): From 4a1e5f055890f910c55cb0cf7a58c3acae1a0bb9 Mon Sep 17 00:00:00 2001 From: Joseph Young <80432516+jpy-git@users.noreply.github.com> Date: Sat, 8 Jan 2022 19:37:16 +0000 Subject: [PATCH 05/10] Update stubs/urllib3/urllib3/exceptions.pyi Co-authored-by: Sebastian Rittau --- stubs/urllib3/urllib3/exceptions.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stubs/urllib3/urllib3/exceptions.pyi b/stubs/urllib3/urllib3/exceptions.pyi index 4ba24a9e741a..a4816ec8e5be 100644 --- a/stubs/urllib3/urllib3/exceptions.pyi +++ b/stubs/urllib3/urllib3/exceptions.pyi @@ -51,6 +51,7 @@ class LocationParseError(LocationValueError): def __init__(self, location: str) -> None: ... class URLSchemeUnknown(LocationValueError): + scheme: str def __init__(self, scheme: str) -> None: ... class ResponseError(HTTPError): From 9a4539f9fc3b5e4d7ee61143220c83c484155d6b Mon Sep 17 00:00:00 2001 From: Joseph Young <80432516+jpy-git@users.noreply.github.com> Date: Sat, 8 Jan 2022 19:45:16 +0000 Subject: [PATCH 06/10] update `reason` instance attribute type --- stubs/urllib3/urllib3/exceptions.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/urllib3/urllib3/exceptions.pyi b/stubs/urllib3/urllib3/exceptions.pyi index a4816ec8e5be..cde97e6e74db 100644 --- a/stubs/urllib3/urllib3/exceptions.pyi +++ b/stubs/urllib3/urllib3/exceptions.pyi @@ -30,7 +30,7 @@ class ProtocolError(HTTPError): ... ConnectionError = ProtocolError class MaxRetryError(RequestError): - reason: Exception | Any + reason: Exception | None def __init__(self, pool: ConnectionPool, url: str, reason: Exception | None = ...) -> None: ... class HostChangedError(RequestError): From 01fbea1af366092a17f1038b8be51fbe602096f9 Mon Sep 17 00:00:00 2001 From: Joseph Young <80432516+jpy-git@users.noreply.github.com> Date: Sun, 9 Jan 2022 20:28:28 +0000 Subject: [PATCH 07/10] Update stubs/urllib3/urllib3/exceptions.pyi Co-authored-by: Alex Waygood --- stubs/urllib3/urllib3/exceptions.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stubs/urllib3/urllib3/exceptions.pyi b/stubs/urllib3/urllib3/exceptions.pyi index cde97e6e74db..46f19624b8c0 100644 --- a/stubs/urllib3/urllib3/exceptions.pyi +++ b/stubs/urllib3/urllib3/exceptions.pyi @@ -70,7 +70,6 @@ class BodyNotHttplibCompatible(HTTPError): ... class IncompleteRead(HTTPError, httplib_IncompleteRead): def __init__(self, partial: bytes, expected: int | None) -> None: ... - def __repr__(self) -> str: ... class InvalidChunkLength(HTTPError, httplib_IncompleteRead): response: HTTPResponse From 3519d4a2dc638fe11b8604f71a6fd732c65aefef Mon Sep 17 00:00:00 2001 From: Joseph Young <80432516+jpy-git@users.noreply.github.com> Date: Sun, 9 Jan 2022 20:28:32 +0000 Subject: [PATCH 08/10] Update stubs/urllib3/urllib3/exceptions.pyi Co-authored-by: Alex Waygood --- stubs/urllib3/urllib3/exceptions.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stubs/urllib3/urllib3/exceptions.pyi b/stubs/urllib3/urllib3/exceptions.pyi index 46f19624b8c0..9edbec401572 100644 --- a/stubs/urllib3/urllib3/exceptions.pyi +++ b/stubs/urllib3/urllib3/exceptions.pyi @@ -75,7 +75,6 @@ class InvalidChunkLength(HTTPError, httplib_IncompleteRead): response: HTTPResponse length: bytes def __init__(self, response: HTTPResponse, length: bytes) -> None: ... - def __repr__(self) -> str: ... class InvalidHeader(HTTPError): ... From 62359781eea48f70b67f25fd172a2edd57d7f6db Mon Sep 17 00:00:00 2001 From: Joseph Young <80432516+jpy-git@users.noreply.github.com> Date: Sun, 9 Jan 2022 20:28:37 +0000 Subject: [PATCH 09/10] Update stubs/urllib3/urllib3/exceptions.pyi Co-authored-by: Alex Waygood --- stubs/urllib3/urllib3/exceptions.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stubs/urllib3/urllib3/exceptions.pyi b/stubs/urllib3/urllib3/exceptions.pyi index 9edbec401572..6cbb2144986b 100644 --- a/stubs/urllib3/urllib3/exceptions.pyi +++ b/stubs/urllib3/urllib3/exceptions.pyi @@ -16,7 +16,6 @@ class PoolError(HTTPError): class RequestError(PoolError): url: str def __init__(self, pool: ConnectionPool, url: str, message: str) -> None: ... - def __reduce__(self) -> tuple[Any, tuple[Any, ...]]: ... class SSLError(HTTPError): ... From 6b3eeb73d68109ec7853cece3dd923aacbbf787f Mon Sep 17 00:00:00 2001 From: Joseph Young <80432516+jpy-git@users.noreply.github.com> Date: Sun, 9 Jan 2022 20:28:42 +0000 Subject: [PATCH 10/10] Update stubs/urllib3/urllib3/exceptions.pyi Co-authored-by: Alex Waygood --- stubs/urllib3/urllib3/exceptions.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stubs/urllib3/urllib3/exceptions.pyi b/stubs/urllib3/urllib3/exceptions.pyi index 6cbb2144986b..8c2090613a8e 100644 --- a/stubs/urllib3/urllib3/exceptions.pyi +++ b/stubs/urllib3/urllib3/exceptions.pyi @@ -11,7 +11,6 @@ class HTTPWarning(Warning): ... class PoolError(HTTPError): pool: ConnectionPool def __init__(self, pool: ConnectionPool, message: str) -> None: ... - def __reduce__(self) -> tuple[Any, tuple[Any, ...]]: ... class RequestError(PoolError): url: str