diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index a00e7406ee1e..f7e1f278d3e6 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -6,7 +6,7 @@ from email.message import Message from http.client import HTTPConnection, HTTPMessage, HTTPResponse from http.cookiejar import CookieJar from re import Pattern -from typing import IO, Any, ClassVar, NoReturn, Protocol, TypeVar, overload, type_check_only +from typing import IO, Any, ClassVar, Literal, NoReturn, Protocol, TypeVar, overload, type_check_only from typing_extensions import TypeAlias, deprecated from urllib.error import HTTPError as HTTPError from urllib.response import addclosehook, addinfourl @@ -65,16 +65,32 @@ if sys.version_info >= (3, 13): ) -> _UrlopenRet: ... else: + @overload def urlopen( url: str | Request, data: _DataType | None = None, timeout: float | None = ..., *, - cafile: str | None = None, - capath: str | None = None, - cadefault: bool = False, + cafile: None = None, + capath: None = None, + cadefault: Literal[False] = False, context: ssl.SSLContext | None = None, ) -> _UrlopenRet: ... + @overload + @deprecated( + "The `cafile`, `capath`, `cadefault` parameters are deprecated since Python 3.6; " + "removed in Python 3.13. Use `context` parameter instead." + ) + def urlopen( + url: str | Request, + data: _DataType | None = None, + timeout: float | None = ..., + *, + cafile: StrOrBytesPath | None = None, + capath: StrOrBytesPath | None = None, + cadefault: bool = False, + context: None = None, + ) -> _UrlopenRet: ... def install_opener(opener: OpenerDirector) -> None: ... def build_opener(*handlers: BaseHandler | Callable[[], BaseHandler]) -> OpenerDirector: ...