Skip to content

Commit 3ee8fc2

Browse files
robertschweizersrittau
authored andcommitted
Add missing Optional types in urllib.parse (#3263)
None values are accepted, and interpreted as empty (byte) strings by some urllib.parse functions.
1 parent 50961d4 commit 3ee8fc2

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

stdlib/3/urllib/parse.pyi

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ class SplitResultBytes(_SplitResultBytesBase, _NetlocResultMixinBytes): ...
8080
class ParseResultBytes(_ParseResultBytesBase, _NetlocResultMixinBytes): ...
8181

8282

83-
def parse_qs(qs: AnyStr, keep_blank_values: bool = ..., strict_parsing: bool = ..., encoding: str = ..., errors: str = ...) -> Dict[AnyStr, List[AnyStr]]: ...
83+
def parse_qs(qs: Optional[AnyStr], keep_blank_values: bool = ..., strict_parsing: bool = ..., encoding: str = ..., errors: str = ...) -> Dict[AnyStr, List[AnyStr]]: ...
8484

85-
def parse_qsl(qs: AnyStr, keep_blank_values: bool = ..., strict_parsing: bool = ..., encoding: str = ..., errors: str = ...) -> List[Tuple[AnyStr, AnyStr]]: ...
85+
def parse_qsl(qs: Optional[AnyStr], keep_blank_values: bool = ..., strict_parsing: bool = ..., encoding: str = ..., errors: str = ...) -> List[Tuple[AnyStr, AnyStr]]: ...
8686

8787

8888
@overload
@@ -106,7 +106,7 @@ def unquote_plus(string: str, encoding: str = ..., errors: str = ...) -> str: ..
106106
@overload
107107
def urldefrag(url: str) -> DefragResult: ...
108108
@overload
109-
def urldefrag(url: bytes) -> DefragResultBytes: ...
109+
def urldefrag(url: Optional[bytes]) -> DefragResultBytes: ...
110110

111111
def urlencode(
112112
query: Union[Mapping[Any, Any], Mapping[Any, Sequence[Any]], Sequence[Tuple[Any, Any]], Sequence[Tuple[Any, Sequence[Any]]]],
@@ -120,21 +120,23 @@ def urlencode(
120120
def urljoin(base: AnyStr, url: Optional[AnyStr], allow_fragments: bool = ...) -> AnyStr: ...
121121

122122
@overload
123-
def urlparse(url: str, scheme: str = ..., allow_fragments: bool = ...) -> ParseResult: ...
123+
def urlparse(url: str, scheme: Optional[str] = ..., allow_fragments: bool = ...) -> ParseResult: ...
124124
@overload
125-
def urlparse(url: bytes, scheme: bytes = ..., allow_fragments: bool = ...) -> ParseResultBytes: ...
125+
def urlparse(url: Optional[bytes], scheme: Optional[bytes] = ..., allow_fragments: bool = ...) -> ParseResultBytes: ...
126126

127127
@overload
128-
def urlsplit(url: str, scheme: str = ..., allow_fragments: bool = ...) -> SplitResult: ...
128+
def urlsplit(url: str, scheme: Optional[str] = ..., allow_fragments: bool = ...) -> SplitResult: ...
129129
@overload
130-
def urlsplit(url: bytes, scheme: bytes = ..., allow_fragments: bool = ...) -> SplitResultBytes: ...
130+
def urlsplit(url: Optional[bytes], scheme: Optional[bytes] = ..., allow_fragments: bool = ...) -> SplitResultBytes: ...
131131

132132
@overload
133-
def urlunparse(components: Tuple[AnyStr, AnyStr, AnyStr, AnyStr, AnyStr, AnyStr]) -> AnyStr: ...
133+
def urlunparse(
134+
components: Tuple[Optional[AnyStr], Optional[AnyStr], Optional[AnyStr], Optional[AnyStr], Optional[AnyStr], Optional[AnyStr]]
135+
) -> AnyStr: ...
134136
@overload
135-
def urlunparse(components: Sequence[AnyStr]) -> AnyStr: ...
137+
def urlunparse(components: Sequence[Optional[AnyStr]]) -> AnyStr: ...
136138

137139
@overload
138-
def urlunsplit(components: Tuple[AnyStr, AnyStr, AnyStr, AnyStr, AnyStr]) -> AnyStr: ...
140+
def urlunsplit(components: Tuple[Optional[AnyStr], Optional[AnyStr], Optional[AnyStr], Optional[AnyStr], Optional[AnyStr]]) -> AnyStr: ...
139141
@overload
140-
def urlunsplit(components: Sequence[AnyStr]) -> AnyStr: ...
142+
def urlunsplit(components: Sequence[Optional[AnyStr]]) -> AnyStr: ...

0 commit comments

Comments
 (0)