Skip to content

bpo-29688: Document Path.absolute #384

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

Closed
wants to merge 6 commits into from
Closed

bpo-29688: Document Path.absolute #384

wants to merge 6 commits into from

Conversation

DimitrisJim
Copy link
Contributor

No description provided.

@mention-bot
Copy link

@DimitrisJim, thanks for your PR! By analyzing the history of the files in this pull request, we identified @eliben, @berkerpeksag, @warsaw, @brettcannon and @ned-deily to be potential reviewers.

Copy link
Contributor

@marco-buttu marco-buttu left a comment

Choose a reason for hiding this comment

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

LGTM. You should just make the code markup on '.' (``'.'``) and '..' (``'..'``), as in the rest of the doc.

@DimitrisJim
Copy link
Contributor Author

Good catch, changed it. Thanks, Marco!

@@ -652,6 +652,18 @@ call fails (for example because the path doesn't exist):
.. versionadded:: 3.5


.. method:: Path.absolute()

Return an absolute version of this path. This function works
Copy link
Member

Choose a reason for hiding this comment

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

Maybe rephrase as "Return an absolute version of this path based on the current working directory"?

.. method:: Path.absolute()

Return an absolute version of this path. This function works
even if the path doesn't point to anything.
Copy link
Member

Choose a reason for hiding this comment

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

"even if the path doesn't exist".

Return an absolute version of this path. This function works
even if the path doesn't point to anything.

No normalization is done, i.e all '.' and '..' will be kept along.
Copy link
Member

Choose a reason for hiding this comment

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

"will be kept along" -> "will not be normalized".

@DimitrisJim
Copy link
Contributor Author

Thanks @brettcannon, made the changes you requested.

Copy link
Contributor

@marco-buttu marco-buttu left a comment

Choose a reason for hiding this comment

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

Much better than the method docstring :-) Thanks @brettcannon :-)

@brettcannon
Copy link
Member

Thanks! When I have time to also do the cherry-pick PRs I will merge.

.. method:: Path.absolute()

Return an absolute version of this path based on the current working
directory. This function works even if the path doesn't exist.
Copy link
Member

Choose a reason for hiding this comment

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

This function => This method

I dislike "works even if", maybe: "This method doesn't check if the path exists." ?

@@ -652,6 +652,18 @@ call fails (for example because the path doesn't exist):
.. versionadded:: 3.5


.. method:: Path.absolute()

Return an absolute version of this path based on the current working
Copy link
Member

Choose a reason for hiding this comment

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

Hum, maybe specify that only relative paths are resolved using the current working directory?

Return an absolute version of this path. Relative paths are resolved using the current working directory.

@vstinner vstinner added the docs Documentation in the Doc dir label Mar 2, 2017
Copy link
Member

@berkerpeksag berkerpeksag left a comment

Choose a reason for hiding this comment

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

Note that the absolute method is barely tested in test_pathlib. https://github.com/python/cpython/blob/master/Lib/test/test_pathlib.py#L1343 is the only place it's indirectly tested.

There is also the following comment in its implementation:

# FIXME this must defer to the specific flavour (and, under Windows,
# use nt._getfullpathname())

https://github.com/python/cpython/blob/master/Lib/pathlib.py#L1096

@vstinner
Copy link
Member

vstinner commented Mar 3, 2017

Oh wow, these comments are scary. I would feel more confortable with a change adding more tests and removing "# FIXME this must defer to the specific flavour (and, under Windows, use nt._getfullpathname())" comment.

@brettcannon
Copy link
Member

That would help explain why it isn't documented. 😉

@DimitrisJim are you up for writing some tests for the function?

@DimitrisJim
Copy link
Contributor Author

I'd rather leave the testing for someone more aware of the intricacies of paths for different OS's. Should we close the PR and rename the issue on b.p.o to something like "pathlib.absolute needs tests and documentation"?

@brettcannon brettcannon closed this Mar 3, 2017
@brettcannon
Copy link
Member

Sure, we can close this for now and re-open if we decide to not deprecate Path.absolute(). Thanks for the PR regardless of whether it gets merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants