Allow urlparse and urlsplit of bytes URLs#9746
Conversation
hauntsaninja
left a comment
There was a problem hiding this comment.
Thanks, this matches the runtime better!
This comment has been minimized.
This comment has been minimized.
AlexWaygood
left a comment
There was a problem hiding this comment.
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 |
|
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 ifurlis 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 forschemeis"", which isn'tbytes | bytearray | None. AddingLiteral[""]to the types forschemewon't cause the overloads to overlap, since they're differentiated by the type ofurl, and will allowurlparseapplied to a singlebytesargument to work again.