-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-37970: update and improve urlparse and urlsplit doc-strings #16458
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
Conversation
Hey @zware, would love to get feedback and close this PR. Ido |
Hi @idomic, sorry I haven't had time to get back to this yet. Some quick high-level feedback, though:
|
@zware fixed all of the above 👍 |
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.
Still need to update urlparse
as well.
@@ -0,0 +1 @@ | |||
Changed documentation for: Lib/urllib/parse.py at the split function |
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.
Updated :func:`urllib.parse.urlsplit` docstring.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
@idomic, please address the review comments. Thanks! |
Codecov Report
@@ Coverage Diff @@
## master #16458 +/- ##
===========================================
+ Coverage 82.20% 83.20% +0.99%
===========================================
Files 1958 1571 -387
Lines 589739 414730 -175009
Branches 44456 44456
===========================================
- Hits 484793 345073 -139720
+ Misses 95287 60016 -35271
+ Partials 9659 9641 -18
Continue to review full report at Codecov.
|
Hey @taleinat adding you to accelerate this PR |
Hi @idomic, It seems you've rebased your branch on a later commit on the master branch, and then merged that with the existing PR branch when pushing it. For future reference, for PR branches, I highly recommend only merging rather than rebasing. If you have rebased, though, you should force-push the rebased branch (i.e. In this case, I suggest you (hard-) reset your branch to the commit before the merge, make sure it's okay, and then force-push that. |
7e1aab6
to
df49504
Compare
Thanks @taleinat Done, let's see if the CI passes |
@idomic, looks good now! For future reference: Please leave a comment with the words |
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.
Lib/urllib/parse.py
Outdated
The scheme, netloc, path, params, query, fragment | ||
of netloc can also be accessed as attributes of the | ||
ParseResult object. |
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.
This is implied directly by the previous sentence, since this is the major feature of named tuples. IMO it would be better to omit this extra sentence. (Same goes for urlsplit()
below.)
Lib/urllib/parse.py
Outdated
@@ -364,11 +364,19 @@ def _fix_result_transcoding(): | |||
del _fix_result_transcoding | |||
|
|||
def urlparse(url, scheme='', allow_fragments=True): | |||
"""Parse a URL into 6 components: | |||
"""Parse URL and return a ParseResult. | |||
SplitResult is a named 6-tuple composed of: |
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.
Copy/paste error here: This returns a ParseResult
object.
Lib/urllib/parse.py
Outdated
@@ -364,11 +364,19 @@ def _fix_result_transcoding(): | |||
del _fix_result_transcoding | |||
|
|||
def urlparse(url, scheme='', allow_fragments=True): | |||
"""Parse a URL into 6 components: | |||
"""Parse URL and return a ParseResult. |
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.
I find this first line less clear than the original (though it is technically correct.)
How about:
"""Parse a URL into 6 components:
<scheme>://<netloc>/<path>;<params>?<query>#<fragment>
The result is a ParseResult object, which is a named 6-tuple with
fields corresponding to the above.
...
This then followed by the later description of the other input parameters and the final note regarding % escapes not being expanded.
(The same goes for urlsplit()
as well.)
@@ -0,0 +1 @@ | |||
Changed documentation for: Lib/urllib/parse.py at the split and parse functions |
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.
This PR changes the doc-strings, not "the documentation", which is what goes up to docs.python.org.
Also, IMO this doesn't warrant a NEWS entry, so it can and should be removed. I'm adding the skip news
label to allow that.
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.
@idomic, please remove this file.
@taleinat Thanks for all the feedback, I noticed I forgot the space line after the doc-string summary. |
I have made the requested changes; please review again |
Lib/urllib/parse.py
Outdated
Note that we don't break the components up in smaller bits | ||
(e.g. netloc is a single string) and we don't expand % escapes.""" | ||
|
||
The result is a ParseResult/SplitResult object, which is a named 6-tuple with |
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.
This will actually be a ParseResult
or a ParseResultBytes
object, depending on the type of the url
parameter. It will never be a SplitResult
object.
Lib/urllib/parse.py
Outdated
Note that we don't break the components up in smaller bits | ||
(e.g. netloc is a single string) and we don't expand % escapes.""" | ||
|
||
The result is a SplitResult object, which is a named 5-tuple with |
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.
This will actually be a SplitResult
or a SplitResultBytes
object, depending on the type of the url
parameter.
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.
Almost done! Two more comments, relevant to both doc-strings.
(Also please remove the NEWS entry file.)
Lib/urllib/parse.py
Outdated
(e.g. netloc is a single string) and we don't expand % escapes.""" | ||
|
||
The result is a ParseResult or ParseResultBytes object, | ||
depending on the type of the URL parameter. |
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.
The parameter is named "url" rather than "URL", let's keep the correct spelling.
depending on the type of the URL parameter. | |
depending on the type of the url parameter. |
Lib/urllib/parse.py
Outdated
The result is a ParseResult or ParseResultBytes object, | ||
depending on the type of the URL parameter. | ||
|
||
The resulting object is a named 6-tuple with fields |
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.
How about, rather than this and the previous paragraphs being separate, something like:
"The result is a named 6-tuple with fields corresponding to the above. It is either a ParseResult or a ParseResultBytes object, depending on the type of the URL parameter."
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.
It's shorter, changed to this version
@@ -0,0 +1 @@ | |||
Changed documentation for: Lib/urllib/parse.py at the split and parse functions |
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.
@idomic, please remove this file.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
I have made the requested changes; please review again |
@taleinat Should I just cherry pick and create a new PR? I see some of the ci fails even after pulling from the master latest version |
@idomic, please don't create a new PR, and there's no need. What you should do is:
|
caef8dd
to
276b695
Compare
Thanks @taleinat , I have made the requested changes; please review again |
276b695
to
82b2473
Compare
@idomic, it seems something went very wrong on your end with this PR's branch. I've gone ahead and force-pushed a fixed version, with a single commit. If you want to check it out locally, note that you'll need to delete your local branch (or rename it to back it up) before pulling this branch. |
Many thanks for the PR, @idomic, and for your patience repeatedly waiting for a review and making the requested changes! I assure you that for changes such as this, it usually doesn't take this long nor as many iterations as it took us here. I hope this experience doesn't discourage you from continuing to contribute to the project! |
@taleinat Not at all, I'm happy to learn and help! |
https://bugs.python.org/issue37970