From 2618e150d015fefe696c5d5815457972f086be96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= Date: Tue, 18 Nov 2025 01:22:05 -0600 Subject: [PATCH] [stdlib] Add a comment to the alias for the return type of `urllib.request.urlopen` (#15042) --- stdlib/urllib/request.pyi | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index 876b9d3f1..a00e7406e 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -49,7 +49,14 @@ if sys.version_info < (3, 14): __all__ += ["URLopener", "FancyURLopener"] _T = TypeVar("_T") + +# The actual type is `addinfourl | HTTPResponse`, but users would need to use `typing.cast` or `isinstance` to narrow the type, +# so we use `Any` instead. +# See +# - https://github.com/python/typeshed/pull/15042 +# - https://github.com/python/typing/issues/566 _UrlopenRet: TypeAlias = Any + _DataType: TypeAlias = ReadableBuffer | SupportsRead[bytes] | Iterable[bytes] | None if sys.version_info >= (3, 13):