From 285b09545fae502c026c12400a0e25b2b4cb1640 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Mon, 30 Jan 2023 23:10:26 +0000 Subject: [PATCH 01/17] `urllib.parse`: Fix issues with TypeVar usage and default values --- stdlib/urllib/parse.pyi | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 17b6a9eb11ef..5b63f938e6b8 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -156,10 +156,30 @@ def urldefrag(url: bytes | bytearray | None) -> DefragResultBytes: ... _Q = TypeVar("_Q", bound=str | Iterable[int]) +@overload +def urlencode( + query: Mapping[Any, Any] | Mapping[Any, Sequence[Any]] | Sequence[tuple[Any, Any]] | Sequence[tuple[Any, Sequence[Any]]], + doseq: bool = False, + safe: str = "", + encoding: str | None = None, + errors: str | None = None, + quote_via: Callable[[AnyStr, str, str, str], str] = ..., +) -> str: ... +@overload +def urlencode( + query: Mapping[Any, Any] | Mapping[Any, Sequence[Any]] | Sequence[tuple[Any, Any]] | Sequence[tuple[Any, Sequence[Any]]], + doseq: bool, + safe: _Q, + encoding: str | None = None, + errors: str | None = None, + quote_via: Callable[[AnyStr, _Q, str, str], str] = ..., +) -> str: ... +@overload def urlencode( query: Mapping[Any, Any] | Mapping[Any, Sequence[Any]] | Sequence[tuple[Any, Any]] | Sequence[tuple[Any, Sequence[Any]]], doseq: bool = False, - safe: _Q = ..., + *, + safe: _Q, encoding: str | None = None, errors: str | None = None, quote_via: Callable[[AnyStr, _Q, str, str], str] = ..., @@ -169,19 +189,19 @@ def urljoin(base: AnyStr, url: AnyStr | None, allow_fragments: bool = True) -> A def urlparse(url: str, scheme: str | None = "", allow_fragments: bool = True) -> ParseResult: ... @overload def urlparse( - url: bytes | bytearray | None, scheme: bytes | bytearray | None = ..., allow_fragments: bool = True + url: bytes | bytearray | None, scheme: bytes | bytearray | None, allow_fragments: bool = True ) -> ParseResultBytes: ... @overload def urlsplit(url: str, scheme: str | None = "", allow_fragments: bool = True) -> SplitResult: ... if sys.version_info >= (3, 11): @overload - def urlsplit(url: bytes | None, scheme: bytes | None = ..., allow_fragments: bool = True) -> SplitResultBytes: ... + def urlsplit(url: bytes | None, scheme: bytes | None, allow_fragments: bool = True) -> SplitResultBytes: ... else: @overload def urlsplit( - url: bytes | bytearray | None, scheme: bytes | bytearray | None = ..., allow_fragments: bool = True + url: bytes | bytearray | None, scheme: bytes | bytearray | Non, allow_fragments: bool = True ) -> SplitResultBytes: ... @overload From 0b93e59df4108062ff8bb7eeeaab3bd3b5befb7b Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 30 Jan 2023 23:15:32 +0000 Subject: [PATCH 02/17] Use a TypeAlias, for readability --- stdlib/urllib/parse.pyi | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 5b63f938e6b8..3cde2cd4ae54 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -1,6 +1,7 @@ import sys from collections.abc import Callable, Iterable, Mapping, Sequence from typing import Any, AnyStr, Generic, NamedTuple, TypeVar, overload +from typing_extensionsn import TypeAlias if sys.version_info >= (3, 9): from types import GenericAlias @@ -155,10 +156,11 @@ def urldefrag(url: str) -> DefragResult: ... def urldefrag(url: bytes | bytearray | None) -> DefragResultBytes: ... _Q = TypeVar("_Q", bound=str | Iterable[int]) +_QueryType: TypeAlias = Mapping[Any, Any] | Mapping[Any, Sequence[Any]] | Sequence[tuple[Any, Any]] | Sequence[tuple[Any, Sequence[Any]]] @overload def urlencode( - query: Mapping[Any, Any] | Mapping[Any, Sequence[Any]] | Sequence[tuple[Any, Any]] | Sequence[tuple[Any, Sequence[Any]]], + query: _QueryType, doseq: bool = False, safe: str = "", encoding: str | None = None, @@ -167,7 +169,7 @@ def urlencode( ) -> str: ... @overload def urlencode( - query: Mapping[Any, Any] | Mapping[Any, Sequence[Any]] | Sequence[tuple[Any, Any]] | Sequence[tuple[Any, Sequence[Any]]], + query: _QueryType, doseq: bool, safe: _Q, encoding: str | None = None, @@ -176,7 +178,7 @@ def urlencode( ) -> str: ... @overload def urlencode( - query: Mapping[Any, Any] | Mapping[Any, Sequence[Any]] | Sequence[tuple[Any, Any]] | Sequence[tuple[Any, Sequence[Any]]], + query: _QueryType, doseq: bool = False, *, safe: _Q, From 74bca69af97a09b7547b6a793674c4451a42ecf1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 Jan 2023 23:16:45 +0000 Subject: [PATCH 03/17] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/urllib/parse.pyi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 3cde2cd4ae54..4bf7e71ae5d0 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -1,6 +1,7 @@ import sys from collections.abc import Callable, Iterable, Mapping, Sequence from typing import Any, AnyStr, Generic, NamedTuple, TypeVar, overload + from typing_extensionsn import TypeAlias if sys.version_info >= (3, 9): @@ -156,7 +157,9 @@ def urldefrag(url: str) -> DefragResult: ... def urldefrag(url: bytes | bytearray | None) -> DefragResultBytes: ... _Q = TypeVar("_Q", bound=str | Iterable[int]) -_QueryType: TypeAlias = Mapping[Any, Any] | Mapping[Any, Sequence[Any]] | Sequence[tuple[Any, Any]] | Sequence[tuple[Any, Sequence[Any]]] +_QueryType: TypeAlias = ( + Mapping[Any, Any] | Mapping[Any, Sequence[Any]] | Sequence[tuple[Any, Any]] | Sequence[tuple[Any, Sequence[Any]]] +) @overload def urlencode( From ea21b821de316c64f4b6d78cca1663198a813744 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 30 Jan 2023 23:17:16 +0000 Subject: [PATCH 04/17] typing_asteatseataestasn;sjdoinasgs --- stdlib/urllib/parse.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 4bf7e71ae5d0..64bb734733ea 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -2,7 +2,7 @@ import sys from collections.abc import Callable, Iterable, Mapping, Sequence from typing import Any, AnyStr, Generic, NamedTuple, TypeVar, overload -from typing_extensionsn import TypeAlias +from typing_extensions import TypeAlias if sys.version_info >= (3, 9): from types import GenericAlias From ccd04f4a61f4ddc7653d30c192bc6c8bf3278158 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 30 Jan 2023 23:18:56 +0000 Subject: [PATCH 05/17] Update stdlib/urllib/parse.pyi --- stdlib/urllib/parse.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 64bb734733ea..c392effb6a63 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -206,7 +206,7 @@ if sys.version_info >= (3, 11): else: @overload def urlsplit( - url: bytes | bytearray | None, scheme: bytes | bytearray | Non, allow_fragments: bool = True + url: bytes | bytearray | None, scheme: bytes | bytearray | None, allow_fragments: bool = True ) -> SplitResultBytes: ... @overload From dd2c74bc5cb493190abbd5e58463239db484dd2d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 Jan 2023 23:19:04 +0000 Subject: [PATCH 06/17] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/urllib/parse.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index c392effb6a63..849834542a74 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -1,7 +1,6 @@ import sys from collections.abc import Callable, Iterable, Mapping, Sequence from typing import Any, AnyStr, Generic, NamedTuple, TypeVar, overload - from typing_extensions import TypeAlias if sys.version_info >= (3, 9): From 309df78d34f3a9322c22acc3e2b73daf6975cf27 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Mon, 30 Jan 2023 23:45:05 +0000 Subject: [PATCH 07/17] Try adding another overload --- stdlib/urllib/parse.pyi | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 849834542a74..1d33d7f516bd 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -196,13 +196,25 @@ def urlparse( url: bytes | bytearray | None, scheme: bytes | bytearray | None, allow_fragments: bool = True ) -> ParseResultBytes: ... @overload +def urlparse( + url: str | bytes | bytearray | None, scheme: str | bytes | bytearray | None = "", allow_fragments: bool = True +) -> ParseResult | ParseResultBytes: ... +@overload def urlsplit(url: str, scheme: str | None = "", allow_fragments: bool = True) -> SplitResult: ... if sys.version_info >= (3, 11): @overload def urlsplit(url: bytes | None, scheme: bytes | None, allow_fragments: bool = True) -> SplitResultBytes: ... + @overload + def urlsplit( + url: str | bytes | None, scheme: str | bytes | None = "", allow_fragments: bool = True + ) -> SplitResult | SplitResultBytes: ... else: + @overload + def urlsplit( + url: str | bytes | bytearray | None, scheme: str | bytes | bytearray | None = "", allow_fragments: bool = True + ) -> SplitResult | SplitResultBytes: ... @overload def urlsplit( url: bytes | bytearray | None, scheme: bytes | bytearray | None, allow_fragments: bool = True From 34a1b111051d186cac87d02f8870150db61ff7b2 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 30 Jan 2023 23:46:24 +0000 Subject: [PATCH 08/17] fix overload order --- stdlib/urllib/parse.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 1d33d7f516bd..8160c2cba6db 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -211,14 +211,14 @@ if sys.version_info >= (3, 11): ) -> SplitResult | SplitResultBytes: ... else: - @overload - def urlsplit( - url: str | bytes | bytearray | None, scheme: str | bytes | bytearray | None = "", allow_fragments: bool = True - ) -> SplitResult | SplitResultBytes: ... @overload def urlsplit( url: bytes | bytearray | None, scheme: bytes | bytearray | None, allow_fragments: bool = True ) -> SplitResultBytes: ... + @overload + def urlsplit( + url: str | bytes | bytearray | None, scheme: str | bytes | bytearray | None = "", allow_fragments: bool = True + ) -> SplitResult | SplitResultBytes: ... @overload def urlunparse( From f103ad0c23ed565dcee50b035aa2d9b91deada19 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Tue, 31 Jan 2023 01:21:22 +0000 Subject: [PATCH 09/17] Tighten up third overloads --- stdlib/urllib/parse.pyi | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 8160c2cba6db..3c527a887a23 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -196,9 +196,7 @@ def urlparse( url: bytes | bytearray | None, scheme: bytes | bytearray | None, allow_fragments: bool = True ) -> ParseResultBytes: ... @overload -def urlparse( - url: str | bytes | bytearray | None, scheme: str | bytes | bytearray | None = "", allow_fragments: bool = True -) -> ParseResult | ParseResultBytes: ... +def urlparse(url: str | None, scheme: Literal[""] = "", allow_fragments: bool = True) -> ParseResult | ParseResultBytes: ... @overload def urlsplit(url: str, scheme: str | None = "", allow_fragments: bool = True) -> SplitResult: ... @@ -206,9 +204,7 @@ if sys.version_info >= (3, 11): @overload def urlsplit(url: bytes | None, scheme: bytes | None, allow_fragments: bool = True) -> SplitResultBytes: ... @overload - def urlsplit( - url: str | bytes | None, scheme: str | bytes | None = "", allow_fragments: bool = True - ) -> SplitResult | SplitResultBytes: ... + def urlsplit(url: str | None, scheme: Literal[""] = "", allow_fragments: bool = True) -> SplitResult | SplitResultBytes: ... else: @overload @@ -216,9 +212,7 @@ else: url: bytes | bytearray | None, scheme: bytes | bytearray | None, allow_fragments: bool = True ) -> SplitResultBytes: ... @overload - def urlsplit( - url: str | bytes | bytearray | None, scheme: str | bytes | bytearray | None = "", allow_fragments: bool = True - ) -> SplitResult | SplitResultBytes: ... + def urlsplit(url: str | None, scheme: Literal[""] = "", allow_fragments: bool = True) -> SplitResult | SplitResultBytes: ... @overload def urlunparse( From 74e022c2ebf64e25eaa4fda373e90bd79ae5ace3 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 31 Jan 2023 01:22:34 +0000 Subject: [PATCH 10/17] add missing import --- stdlib/urllib/parse.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 3c527a887a23..4b8624869ada 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -1,7 +1,7 @@ import sys from collections.abc import Callable, Iterable, Mapping, Sequence from typing import Any, AnyStr, Generic, NamedTuple, TypeVar, overload -from typing_extensions import TypeAlias +from typing_extensions import Literal, TypeAlias if sys.version_info >= (3, 9): from types import GenericAlias From 87fb917d86e642b1020b162388bd564d61663c87 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 31 Jan 2023 01:23:14 +0000 Subject: [PATCH 11/17] Update stdlib/urllib/parse.pyi Co-authored-by: Jelle Zijlstra --- stdlib/urllib/parse.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 4b8624869ada..2c0741983758 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -198,7 +198,7 @@ def urlparse( @overload def urlparse(url: str | None, scheme: Literal[""] = "", allow_fragments: bool = True) -> ParseResult | ParseResultBytes: ... @overload -def urlsplit(url: str, scheme: str | None = "", allow_fragments: bool = True) -> SplitResult: ... +def urlsplit(url: str, scheme: str = "", allow_fragments: bool = True) -> SplitResult: ... if sys.version_info >= (3, 11): @overload From 046b86863ee0f0116d5dd68c4f01ed544870951a Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 31 Jan 2023 01:25:39 +0000 Subject: [PATCH 12/17] simplify --- stdlib/urllib/parse.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 2c0741983758..c9a22a13dd68 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -197,22 +197,22 @@ def urlparse( ) -> ParseResultBytes: ... @overload def urlparse(url: str | None, scheme: Literal[""] = "", allow_fragments: bool = True) -> ParseResult | ParseResultBytes: ... + @overload def urlsplit(url: str, scheme: str = "", allow_fragments: bool = True) -> SplitResult: ... if sys.version_info >= (3, 11): @overload def urlsplit(url: bytes | None, scheme: bytes | None, allow_fragments: bool = True) -> SplitResultBytes: ... - @overload - def urlsplit(url: str | None, scheme: Literal[""] = "", allow_fragments: bool = True) -> SplitResult | SplitResultBytes: ... else: @overload def urlsplit( url: bytes | bytearray | None, scheme: bytes | bytearray | None, allow_fragments: bool = True ) -> SplitResultBytes: ... - @overload - def urlsplit(url: str | None, scheme: Literal[""] = "", allow_fragments: bool = True) -> SplitResult | SplitResultBytes: ... + +@overload +def urlsplit(url: str | None, scheme: Literal[""] = "", allow_fragments: bool = True) -> SplitResult | SplitResultBytes: ... @overload def urlunparse( From 8cdd012a5c22b69e5b994567a40287c5fa698689 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 31 Jan 2023 01:26:46 +0000 Subject: [PATCH 13/17] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/urllib/parse.pyi | 2 -- 1 file changed, 2 deletions(-) diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index c9a22a13dd68..939feabab57b 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -197,7 +197,6 @@ def urlparse( ) -> ParseResultBytes: ... @overload def urlparse(url: str | None, scheme: Literal[""] = "", allow_fragments: bool = True) -> ParseResult | ParseResultBytes: ... - @overload def urlsplit(url: str, scheme: str = "", allow_fragments: bool = True) -> SplitResult: ... @@ -213,7 +212,6 @@ else: @overload def urlsplit(url: str | None, scheme: Literal[""] = "", allow_fragments: bool = True) -> SplitResult | SplitResultBytes: ... - @overload def urlunparse( components: tuple[AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None] From f63418addfdbc29ad59ebe98af2f9153cf077683 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 31 Jan 2023 01:31:13 +0000 Subject: [PATCH 14/17] Update stdlib/urllib/parse.pyi Co-authored-by: Jelle Zijlstra --- stdlib/urllib/parse.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 939feabab57b..1b7a47dddf2e 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -190,7 +190,7 @@ def urlencode( ) -> str: ... def urljoin(base: AnyStr, url: AnyStr | None, allow_fragments: bool = True) -> AnyStr: ... @overload -def urlparse(url: str, scheme: str | None = "", allow_fragments: bool = True) -> ParseResult: ... +def urlparse(url: str, scheme: str = "", allow_fragments: bool = True) -> ParseResult: ... @overload def urlparse( url: bytes | bytearray | None, scheme: bytes | bytearray | None, allow_fragments: bool = True From 16c49411e765e2ed61c5b7c5433460d0f4e26091 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 31 Jan 2023 01:44:17 +0000 Subject: [PATCH 15/17] Try Jelle's version Co-authored-by: Jelle Zijlstra --- stdlib/urllib/parse.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 1b7a47dddf2e..5fc8bcbd46e8 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -196,7 +196,7 @@ def urlparse( url: bytes | bytearray | None, scheme: bytes | bytearray | None, allow_fragments: bool = True ) -> ParseResultBytes: ... @overload -def urlparse(url: str | None, scheme: Literal[""] = "", allow_fragments: bool = True) -> ParseResult | ParseResultBytes: ... +def urlparse(url: None, scheme: Literal[""] = "", allow_fragments: bool = True) -> ParseResultBytes: ... @overload def urlsplit(url: str, scheme: str = "", allow_fragments: bool = True) -> SplitResult: ... From 79f3be3023da9db672b70cd5c03b781ef0cbb5af Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 31 Jan 2023 02:05:42 +0000 Subject: [PATCH 16/17] Improve --- stdlib/urllib/parse.pyi | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 5fc8bcbd46e8..77589a036ca0 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -193,25 +193,27 @@ def urljoin(base: AnyStr, url: AnyStr | None, allow_fragments: bool = True) -> A def urlparse(url: str, scheme: str = "", allow_fragments: bool = True) -> ParseResult: ... @overload def urlparse( - url: bytes | bytearray | None, scheme: bytes | bytearray | None, allow_fragments: bool = True + url: bytes | bytearray, scheme: bytes | bytearray | None, allow_fragments: bool = True ) -> ParseResultBytes: ... @overload -def urlparse(url: None, scheme: Literal[""] = "", allow_fragments: bool = True) -> ParseResultBytes: ... +def urlparse(url: None, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True) -> ParseResultBytes: ... @overload def urlsplit(url: str, scheme: str = "", allow_fragments: bool = True) -> SplitResult: ... if sys.version_info >= (3, 11): @overload - def urlsplit(url: bytes | None, scheme: bytes | None, allow_fragments: bool = True) -> SplitResultBytes: ... + def urlsplit(url: bytes, scheme: bytes | None, allow_fragments: bool = True) -> SplitResultBytes: ... + @overload + def urlsplit(url: None, scheme: bytes | None | Literal[""] = "", allow_fragments: bool = True) -> SplitResultBytes: ... else: @overload def urlsplit( - url: bytes | bytearray | None, scheme: bytes | bytearray | None, allow_fragments: bool = True + url: bytes | bytearray, scheme: bytes | bytearray | None, allow_fragments: bool = True ) -> SplitResultBytes: ... + @overload + def urlsplit(url: None, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True) -> SplitResultBytes: ... -@overload -def urlsplit(url: str | None, scheme: Literal[""] = "", allow_fragments: bool = True) -> SplitResult | SplitResultBytes: ... @overload def urlunparse( components: tuple[AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None] From e535cffd66907576a85a4ed12572a3aa8a554b65 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 31 Jan 2023 02:06:55 +0000 Subject: [PATCH 17/17] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/urllib/parse.pyi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 77589a036ca0..cd1d9347d6f7 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -192,12 +192,12 @@ def urljoin(base: AnyStr, url: AnyStr | None, allow_fragments: bool = True) -> A @overload def urlparse(url: str, scheme: str = "", allow_fragments: bool = True) -> ParseResult: ... @overload +def urlparse(url: bytes | bytearray, scheme: bytes | bytearray | None, allow_fragments: bool = True) -> ParseResultBytes: ... +@overload def urlparse( - url: bytes | bytearray, scheme: bytes | bytearray | None, allow_fragments: bool = True + url: None, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True ) -> ParseResultBytes: ... @overload -def urlparse(url: None, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True) -> ParseResultBytes: ... -@overload def urlsplit(url: str, scheme: str = "", allow_fragments: bool = True) -> SplitResult: ... if sys.version_info >= (3, 11): @@ -207,12 +207,12 @@ if sys.version_info >= (3, 11): def urlsplit(url: None, scheme: bytes | None | Literal[""] = "", allow_fragments: bool = True) -> SplitResultBytes: ... else: + @overload + def urlsplit(url: bytes | bytearray, scheme: bytes | bytearray | None, allow_fragments: bool = True) -> SplitResultBytes: ... @overload def urlsplit( - url: bytes | bytearray, scheme: bytes | bytearray | None, allow_fragments: bool = True + url: None, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True ) -> SplitResultBytes: ... - @overload - def urlsplit(url: None, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True) -> SplitResultBytes: ... @overload def urlunparse(