drivendataorg / drivendataorg/cloudpathlib

replace and rename don't handle "directories"

Open
#64 0 comments 0 reactions 0 assignees View on GitHub
bug design decision good first issue S3
Dominant language
Python
Stars
628
Forks
88
Avg merge
17h 28m
Merged PRs (30d)
2

Description

`CloudPath.replace` and `CloudPath.rename` (which are the same function for cloudpathlib) do not handle "directories".

The pathlib docs say:

```
Rename this file or directory to the given target, and return a new Path instance pointing to target. If target points to an existing file or directory, it will be unconditionally replaced.
```

```
>>> from cloudpathlib import CloudPath
>>> s = CloudPath("s3://my-bucket/")
>>> (s / "foo" / "bar.txt").touch()
>>> (s / "foo").replace(s / "baz")
Traceback (most recent call last):
...
botocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation: Not Found
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.