11import sys
22from collections .abc import Callable , Mapping , Sequence
33from typing import Any , AnyStr , Generic , NamedTuple , overload
4- from typing_extensions import TypeAlias
54
65if sys .version_info >= (3 , 9 ):
76 from types import GenericAlias
@@ -30,8 +29,6 @@ __all__ = [
3029 "SplitResultBytes" ,
3130]
3231
33- _Str : TypeAlias = bytes | str
34-
3532uses_relative : list [str ]
3633uses_netloc : list [str ]
3734uses_params : list [str ]
@@ -135,16 +132,22 @@ def parse_qsl(
135132 separator : str = ...,
136133) -> list [tuple [AnyStr , AnyStr ]]: ...
137134@overload
138- def quote (string : str , safe : _Str = ..., encoding : str | None = ..., errors : str | None = ...) -> str : ...
135+ def quote (string : str , safe : str | bytes = ..., encoding : str | None = ..., errors : str | None = ...) -> str : ...
139136@overload
140- def quote (string : bytes , safe : _Str = ...) -> str : ...
141- def quote_from_bytes (bs : bytes , safe : _Str = ...) -> str : ...
137+ def quote (string : bytes , safe : str | bytes = ...) -> str : ...
138+ def quote_from_bytes (bs : bytes , safe : str | bytes = ...) -> str : ...
142139@overload
143- def quote_plus (string : str , safe : _Str = ..., encoding : str | None = ..., errors : str | None = ...) -> str : ...
140+ def quote_plus (string : str , safe : str | bytes = ..., encoding : str | None = ..., errors : str | None = ...) -> str : ...
144141@overload
145- def quote_plus (string : bytes , safe : _Str = ...) -> str : ...
146- def unquote (string : str , encoding : str = ..., errors : str = ...) -> str : ...
147- def unquote_to_bytes (string : _Str ) -> bytes : ...
142+ def quote_plus (string : bytes , safe : str | bytes = ...) -> str : ...
143+
144+ if sys .version_info >= (3 , 9 ):
145+ def unquote (string : str | bytes , encoding : str = ..., errors : str = ...) -> str : ...
146+
147+ else :
148+ def unquote (string : str , encoding : str = ..., errors : str = ...) -> str : ...
149+
150+ def unquote_to_bytes (string : str | bytes ) -> bytes : ...
148151def unquote_plus (string : str , encoding : str = ..., errors : str = ...) -> str : ...
149152@overload
150153def urldefrag (url : str ) -> DefragResult : ...
@@ -153,10 +156,10 @@ def urldefrag(url: bytes | None) -> DefragResultBytes: ...
153156def urlencode (
154157 query : Mapping [Any , Any ] | Mapping [Any , Sequence [Any ]] | Sequence [tuple [Any , Any ]] | Sequence [tuple [Any , Sequence [Any ]]],
155158 doseq : bool = ...,
156- safe : _Str = ...,
159+ safe : str | bytes = ...,
157160 encoding : str = ...,
158161 errors : str = ...,
159- quote_via : Callable [[AnyStr , _Str , str , str ], str ] = ...,
162+ quote_via : Callable [[AnyStr , str | bytes , str , str ], str ] = ...,
160163) -> str : ...
161164def urljoin (base : AnyStr , url : AnyStr | None , allow_fragments : bool = ...) -> AnyStr : ...
162165@overload
0 commit comments