Skip to content

Conversation

@edgarrmondragon
Copy link
Contributor

No description provided.

@github-actions

This comment has been minimized.

@srittau
Copy link
Collaborator

srittau commented Nov 17, 2025

Unfortunately, this would require every user of urlopen() to add a cast or isinstance check, so it's not feasible to change this. But it's a case where python/typing#566 would be useful. That said, we should add an appropriate comment to the type var, explaining the expected return types.

@edgarrmondragon
Copy link
Contributor Author

Unfortunately, this would require every user of urlopen() to add a cast or isinstance check, so it's not feasible to change this. But it's a case where python/typing#566 would be useful.

Thanks @srittau, I see that now. Even in my own code which motivated this change, I'd need to add a type assertion to make it actually work after this change.

That said, we should add an appropriate comment to the type var, explaining the expected return types.

You mean to _UrlopenRet?

@srittau
Copy link
Collaborator

srittau commented Nov 17, 2025

You mean to _UrlopenRet?

Yes. If you want to, you can change this PR accordingly. Otherwise, I'll add a comment.

@edgarrmondragon
Copy link
Contributor Author

Yes. If you want to, you can change this PR accordingly. Otherwise, I'll add a comment.

I'll do that

`urllib.request.urlopen`

It explains the actual expected types and why `Any` is used.

Signed-off-by: Edgar Ramírez-Mondragón <edgarrm358@gmail.com>
@edgarrmondragon edgarrmondragon changed the title [stdlib] Update the return type of urllib.request.urlopen to urllib.response.addinfourl | http.client.HTTPResponse [stdlib] Add a comment to the alias for the return type of urllib.request.urlopen Nov 18, 2025
@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@edgarrmondragon edgarrmondragon marked this pull request as ready for review November 18, 2025 01:19
Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@srittau srittau merged commit 2618e15 into python:main Nov 18, 2025
63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants