From 0bab4640cf218af9903b75fde988e46d959f401a Mon Sep 17 00:00:00 2001 From: Max Murin Date: Fri, 17 Feb 2023 00:49:11 -0800 Subject: [PATCH 1/4] add default value to bytes overload of urlsplit and urlparse --- stdlib/urllib/parse.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index cd1d9347d6f7..487f44a71109 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -192,7 +192,7 @@ 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: ... +def urlparse(url: bytes | bytearray, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True) -> ParseResultBytes: ... @overload def urlparse( url: None, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True @@ -202,13 +202,13 @@ def urlsplit(url: str, scheme: str = "", allow_fragments: bool = True) -> SplitR if sys.version_info >= (3, 11): @overload - def urlsplit(url: bytes, scheme: bytes | None, allow_fragments: bool = True) -> SplitResultBytes: ... + def urlsplit(url: bytes, scheme: bytes | None | Literal[""] = "", 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, scheme: bytes | bytearray | None, allow_fragments: bool = True) -> SplitResultBytes: ... + def urlsplit(url: bytes | bytearray, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True) -> SplitResultBytes: ... @overload def urlsplit( url: None, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True From 71a2d85fb3b85934f7a80608bbd689921d5cd791 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 17 Feb 2023 08:54:01 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/urllib/parse.pyi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 487f44a71109..381f8ed4d3f4 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -192,7 +192,9 @@ 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 | Literal[""] = "", allow_fragments: bool = True) -> ParseResultBytes: ... +def urlparse( + url: bytes | bytearray, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True +) -> ParseResultBytes: ... @overload def urlparse( url: None, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True @@ -208,7 +210,9 @@ if sys.version_info >= (3, 11): else: @overload - def urlsplit(url: bytes | bytearray, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True) -> SplitResultBytes: ... + def urlsplit( + url: bytes | bytearray, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True + ) -> SplitResultBytes: ... @overload def urlsplit( url: None, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True From 670a7b21fbbc876f866b598c3972d08b1e3955f8 Mon Sep 17 00:00:00 2001 From: Max Murin Date: Fri, 17 Feb 2023 12:41:12 -0800 Subject: [PATCH 3/4] merge second and third overloads --- stdlib/urllib/parse.pyi | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 381f8ed4d3f4..177df81a4f2e 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -193,29 +193,18 @@ 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, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True -) -> ParseResultBytes: ... -@overload -def urlparse( - url: None, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True + url: bytes | bytearray | 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, scheme: bytes | None | Literal[""] = "", allow_fragments: bool = True) -> SplitResultBytes: ... - @overload - def urlsplit(url: None, scheme: bytes | None | Literal[""] = "", allow_fragments: bool = True) -> SplitResultBytes: ... - + def urlsplit(url: bytes | None, scheme: bytes | None | Literal[""] = "", allow_fragments: bool = True) -> SplitResultBytes: ... else: @overload def urlsplit( - url: bytes | bytearray, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True - ) -> SplitResultBytes: ... - @overload - def urlsplit( - url: None, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True + url: bytes | bytearray | None, scheme: bytes | bytearray | None | Literal[""] = "", allow_fragments: bool = True ) -> SplitResultBytes: ... @overload From b8dccd668a0fb65d080e47d064c7d90ccd2c03cc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 17 Feb 2023 20:42:31 +0000 Subject: [PATCH 4/4] [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 177df81a4f2e..50c5d44cdd80 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -200,7 +200,10 @@ def urlsplit(url: str, scheme: str = "", allow_fragments: bool = True) -> SplitR if sys.version_info >= (3, 11): @overload - def urlsplit(url: bytes | None, scheme: bytes | None | Literal[""] = "", allow_fragments: bool = True) -> SplitResultBytes: ... + def urlsplit( + url: bytes | None, scheme: bytes | None | Literal[""] = "", allow_fragments: bool = True + ) -> SplitResultBytes: ... + else: @overload def urlsplit(