Skip to content

Commit 2618e15

Browse files
[stdlib] Add a comment to the alias for the return type of urllib.request.urlopen (#15042)
1 parent bbbf753 commit 2618e15

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

stdlib/urllib/request.pyi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,14 @@ if sys.version_info < (3, 14):
4949
__all__ += ["URLopener", "FancyURLopener"]
5050

5151
_T = TypeVar("_T")
52+
53+
# The actual type is `addinfourl | HTTPResponse`, but users would need to use `typing.cast` or `isinstance` to narrow the type,
54+
# so we use `Any` instead.
55+
# See
56+
# - https://github.com/python/typeshed/pull/15042
57+
# - https://github.com/python/typing/issues/566
5258
_UrlopenRet: TypeAlias = Any
59+
5360
_DataType: TypeAlias = ReadableBuffer | SupportsRead[bytes] | Iterable[bytes] | None
5461

5562
if sys.version_info >= (3, 13):

0 commit comments

Comments
 (0)