Skip to content
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

Improve compatibility with pathlib by implementing more common methods #230

Merged
merged 16 commits into from
May 31, 2022

Conversation

Gilthans
Copy link
Contributor

@Gilthans Gilthans commented May 30, 2022

#149, #151

  • Added absolute and resolve, which do nothing. This allows the methods to be called when the path type is unknown
  • Support PurePosixPath in truediv. This allows combining a cloudpath with a relative path from elsewhere (and is more consistent with joinpaths which already supports PurePosixPath as a parameter)
  • Added relative_to, which returns a relative PurePosixPath
  • Added is_absolute and is_relative_to
  • Accept and delegate read_text parameters
  • Add exist_ok parameter to touch
  • Add missing_ok parameter to unlink. Even though it defaults to False in pathlib, adding it with that default would be a breaking change, since current implementation doesn't check for existence, so I added it defaulting to True.

@Gilthans
Copy link
Contributor Author

I added a few more compatibility changes:

  • is_absolute and is_relative_to added
  • Accept and delegate read_text parameters
  • Add exist_ok parameter to touch
  • Add missing_ok parameter to unlink. Even though it defaults to False in pathlib, adding it with that default would be a breaking change, since current implementation doesn't check for existence, so I added it defaulting to True.

Copy link
Member

@pjbull pjbull left a comment

Choose a reason for hiding this comment

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

Awesome PR, thanks @Gilthans !

In addition to the comments, could you:

  • (1) make linting pass (make format then make lint should check this for you)
  • (2) update the README.md so the table reflects the new supported methods
  • (3) add a note to HISTORY.md with the updates

cloudpathlib/cloudpath.py Outdated Show resolved Hide resolved
cloudpathlib/cloudpath.py Show resolved Hide resolved
cloudpathlib/cloudpath.py Show resolved Hide resolved
cloudpathlib/gs/gsclient.py Outdated Show resolved Hide resolved
tests/test_cloudpath_manipulation.py Outdated Show resolved Hide resolved
@Gilthans Gilthans requested a review from pjbull May 31, 2022 14:09
@codecov-commenter
Copy link

codecov-commenter commented May 31, 2022

Codecov Report

Merging #230 (b072b42) into master (da86719) will decrease coverage by 0.3%.
The diff coverage is 96.5%.

@@           Coverage Diff            @@
##           master    #230     +/-   ##
========================================
- Coverage    94.7%   94.4%   -0.4%     
========================================
  Files          21      21             
  Lines        1287    1323     +36     
========================================
+ Hits         1219    1249     +30     
- Misses         68      74      +6     
Impacted Files Coverage Δ
cloudpathlib/cloudpath.py 93.3% <92.0%> (+<0.1%) ⬆️
cloudpathlib/azure/azblobclient.py 94.3% <100.0%> (+0.1%) ⬆️
cloudpathlib/azure/azblobpath.py 92.7% <100.0%> (+0.2%) ⬆️
cloudpathlib/client.py 87.9% <100.0%> (ø)
cloudpathlib/gs/gsclient.py 92.8% <100.0%> (-1.7%) ⬇️
cloudpathlib/gs/gspath.py 94.1% <100.0%> (+0.2%) ⬆️
cloudpathlib/local/localclient.py 96.5% <100.0%> (+0.1%) ⬆️
cloudpathlib/local/localpath.py 94.4% <100.0%> (ø)
cloudpathlib/s3/s3client.py 92.9% <100.0%> (-2.6%) ⬇️
cloudpathlib/s3/s3path.py 97.9% <100.0%> (+<0.1%) ⬆️
... and 2 more

Copy link
Member

@pjbull pjbull left a comment

Choose a reason for hiding this comment

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

A couple documentation tweaks, and then testing for the cloud_prefix and this should be good to go.

For the failing docs build in CI, can you update requirements-dev.txt with a change like the one we had to make in another project?
https://github.com/drivendataorg/nbautoexport/pull/96/files

cloudpathlib/cloudpath.py Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
HISTORY.md Outdated Show resolved Hide resolved
HISTORY.md Outdated Show resolved Hide resolved
@Gilthans Gilthans requested a review from pjbull May 31, 2022 17:41
@Gilthans Gilthans requested a review from pjbull May 31, 2022 19:30
@pjbull pjbull changed the base branch from master to 230-live-tests May 31, 2022 23:04
@pjbull
Copy link
Member

pjbull commented May 31, 2022

Thanks @Gilthans! Moving this on to a contributor branch to run the live tests.

@pjbull pjbull merged commit 6360893 into drivendataorg:230-live-tests May 31, 2022
@pjbull pjbull added the review label May 31, 2022
pjbull added a commit that referenced this pull request Jun 1, 2022
#230) (#232)

* Added absolute, resolve and relative_to implementations

* Added tests interacting with PurePosixPaths

* Added is_absolute and is_relative_to as well

* Accept read_text parameters

* Added exist_ok paramter to touch

* Added missing_ok paramter to unlink

* Fixed formatting (make format)

* Update history.md & readme.md

* Fix relative_to on different providers (+ some naming changes

* Reformat

* Update history.md and bump version number to 0.9

* Update dev requirements for docs

* Fix readme list order

* Added test for relative_to on different provider cloud paths

* Remove unused import

* Updated relative_to different cloud test

Co-authored-by: Daniel Rembiszewski <gilthans@gmail.com>
@pjbull
Copy link
Member

pjbull commented Jun 1, 2022

Merged into the main branch, thanks @Gilthans !

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

Successfully merging this pull request may close these issues.

3 participants