add and test URL.__str__, which enables URLs to be passed directly to… - #55
Conversation
… libaries which stringify (like requests). fixes #49.
Codecov Report
@@ Coverage Diff @@
## master #55 +/- ##
=========================================
+ Coverage 97.76% 97.8% +0.03%
=========================================
Files 6 6
Lines 1118 1137 +19
Branches 135 137 +2
=========================================
+ Hits 1093 1112 +19
Misses 13 13
Partials 12 12
Continue to review full report at Codecov.
|
|
Rather than adding the "some libraries are bad at IRIs" in a private docstring that I guarantee you no one will ever read, if the goal here is |
|
The "some libraries are bad at IRIs" is just a hint of a glimmer of something I remember, combined with general suspicion. I'm fine with the always |
glyph
left a comment
There was a problem hiding this comment.
Please file a follow-up ticket to add documentation showing that this is an intentional integration point with Requests.
(And we should probably make sure it works with Treq too, although I'm not sure if it does right now.)
This
URL.__str__()enables URLs to be passed directly to libaries which stringify (like requests), as brought up by issue #49.I've opted to keep it simple and have Python 2's
__str__(Py3's__bytes__()) return the UTF-8 encoded version ofURL.to_text(). This means that when printed on terminals configured to display UTF-8, the user will get a copy-and-pastable URL.I also considered making
__str__return the ASCII-encodedURL.to_url().to_text(), but this would have the property of obscuring special characters and possibly falsely-equating URIs and IRIs, contrary to hyperlink's longstanding design.