-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow urlparse and urlsplit of bytes URLs #9746
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this matches the runtime better!
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks like we could actually combine the first two overloads of urlparse
and urlsplit
in that case — want to do that?
Is there an easy way to do that? It seems hard to me since they still have different return types, but if there's a good way to combine them then I'll do it. |
|
Sorry, I meant to combine the second and third overloads, not the first two overloads! Apologies for the garbled review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Syncing typeshed again to make sure python/typeshed#9746 gets into the 1.1 release.
Right now,
urlparse(url)
andurlsplit(url)
doesn't work ifurl
is abytes
. This is because the only overload that can match this case is the one whereurl: bytes | bytearray
, but even this one doesn't match since the default value forscheme
is""
, which isn'tbytes | bytearray | None
. AddingLiteral[""]
to the types forscheme
won't cause the overloads to overlap, since they're differentiated by the type ofurl
, and will allowurlparse
applied to a singlebytes
argument to work again.