Skip to content

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

Merged
merged 1 commit into from
Feb 16, 2020

Conversation

idomic
Copy link
Contributor

@idomic idomic commented Sep 28, 2019

@idomic
Copy link
Contributor Author

idomic commented Oct 3, 2019

Hey @zware, would love to get feedback and close this PR.

Ido

@zware
Copy link
Member

zware commented Oct 3, 2019

Hi @idomic, sorry I haven't had time to get back to this yet. Some quick high-level feedback, though:

  • CI is failing, so that will need to be addressed. Without digging in and looking, the most likely culprit is trailing whitespace; run make patchcheck if you're on a *nix platform, or run the same commands that does if you're on Windows (yes, terrible UX there, sorry :( ).
  • There should be a NEWS entry for this, see the Details link on the bedevere/news check.
  • urlparse needs approximately the same treatment.
  • It would be good to go through the rest of the module and see if there are other similarly insufficient docstrings that could be updated while we're in there.

@idomic
Copy link
Contributor Author

idomic commented Dec 3, 2019

@zware fixed all of the above 👍

Copy link
Member

@zware zware left a 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
Copy link
Member

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.

@bedevere-bot
Copy link

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. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@csabella
Copy link
Contributor

@idomic, please address the review comments. Thanks!

@idomic
Copy link
Contributor Author

idomic commented Feb 2, 2020

Thanks @zware @csabella and sorry for the delay!
Fixed the fixed the review comments, let's see if the CI passes.

@idomic
Copy link
Contributor Author

idomic commented Feb 8, 2020

Thanks @zware @csabella and sorry for the delay!
Fixed the fixed the review comments, let's see if the CI passes.

Added the documentation for the parseurl function as well.
@zware @csabella looks like everything passed fine?

@codecov
Copy link

codecov bot commented Feb 8, 2020

Codecov Report

Merging #16458 into master will increase coverage by 0.99%.
The diff coverage is n/a.

Impacted file tree graph

@@             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     
Impacted Files Coverage Δ
Lib/distutils/tests/test_bdist_rpm.py 30.00% <0.00%> (-65.00%) ⬇️
Lib/distutils/command/bdist_rpm.py 7.63% <0.00%> (-56.88%) ⬇️
Lib/test/test_urllib2net.py 76.92% <0.00%> (-13.85%) ⬇️
Lib/test/test_smtpnet.py 78.57% <0.00%> (-12.86%) ⬇️
Lib/ftplib.py 63.85% <0.00%> (-6.06%) ⬇️
Lib/test/test_ftplib.py 87.11% <0.00%> (-4.72%) ⬇️
Lib/dbm/__init__.py 66.66% <0.00%> (-4.45%) ⬇️
Tools/scripts/db2pickle.py 17.82% <0.00%> (-3.97%) ⬇️
Lib/test/test_socket.py 71.94% <0.00%> (-3.87%) ⬇️
Tools/scripts/pickle2db.py 16.98% <0.00%> (-3.78%) ⬇️
... and 428 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1ed6161...82b2473. Read the comment docs.

@csabella csabella requested a review from zware February 9, 2020 18:41
@idomic
Copy link
Contributor Author

idomic commented Feb 11, 2020

Hey @taleinat adding you to accelerate this PR

@taleinat
Copy link
Contributor

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. git push -f origin <branch-name>).

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.

@idomic
Copy link
Contributor Author

idomic commented Feb 11, 2020

Thanks @taleinat Done, let's see if the CI passes

@taleinat
Copy link
Contributor

@idomic, looks good now!

For future reference: Please leave a comment with the words I have made the requested changes; please review again after a committer has requested changes; this will trigger a bot to update the state tags and notify the reviewer.

Copy link
Contributor

@taleinat taleinat left a comment

Choose a reason for hiding this comment

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

As mentioned by @zware, the suggested doc-strings don't follow the guidelines in PEP 257. In addition to my other comments, please fix their formatting.

Comment on lines 370 to 372
The scheme, netloc, path, params, query, fragment
of netloc can also be accessed as attributes of the
ParseResult object.
Copy link
Contributor

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.)

@@ -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:
Copy link
Contributor

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.

@@ -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.
Copy link
Contributor

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
Copy link
Contributor

@taleinat taleinat Feb 11, 2020

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.

Copy link
Contributor

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.

@idomic
Copy link
Contributor Author

idomic commented Feb 12, 2020

@taleinat Thanks for all the feedback, I noticed I forgot the space line after the doc-string summary.
Did took your version as it clarifies the role in less lines.

@idomic
Copy link
Contributor Author

idomic commented Feb 12, 2020

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@taleinat, @zware: please review the changes made to this pull request.

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
Copy link
Contributor

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.

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
Copy link
Contributor

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.

Copy link
Contributor

@taleinat taleinat left a 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.)

(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.
Copy link
Contributor

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.

Suggested change
depending on the type of the URL parameter.
depending on the type of the url parameter.

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
Copy link
Contributor

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."

Copy link
Contributor Author

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
Copy link
Contributor

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.

@bedevere-bot
Copy link

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. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@idomic
Copy link
Contributor Author

idomic commented Feb 13, 2020

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@zware, @taleinat: please review the changes made to this pull request.

@idomic
Copy link
Contributor Author

idomic commented Feb 14, 2020

@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

@taleinat
Copy link
Contributor

taleinat commented Feb 16, 2020

@idomic, please don't create a new PR, and there's no need. What you should do is:

  1. Hard-reset your branch to the latest master branch
  2. Make the latest appropriate changes (even copy-paste from GitHub works)
  3. Review, making sure everything is fine
  4. run make patchcheck (or run patchcheck.py directly on Windows)
  5. Create a new commit with appropriate prefix: [bpo-37970](https://bugs.python.org/issue37970):
  6. Force-push into this PR's branch

@idomic
Copy link
Contributor Author

idomic commented Feb 16, 2020

Thanks @taleinat , I have made the requested changes; please review again
Let's see how it goes!

@bedevere-bot
Copy link

Thanks for making the requested changes!

@taleinat, @zware: please review the changes made to this pull request.

@taleinat
Copy link
Contributor

@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.

@taleinat taleinat changed the title bpo-37970 Fixed urlsplit docstrings in urllib/parse.py bpo-37970: update and improve urlparse and urlsplit doc-strings Feb 16, 2020
@taleinat
Copy link
Contributor

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!

@idomic
Copy link
Contributor Author

idomic commented Feb 16, 2020

@taleinat Not at all, I'm happy to learn and help!
Hopefully our next work will be more concise :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants