drivendataorg / drivendataorg/cloudpathlib

`AnyPath.rmtree()` does not work with local paths

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

Description

I'm using `cloudpathlib.AnyPath` to be able to fall back to a local filesystem for e.g. testing. However, it seems that `AnyPath.rmtree()` does not work correctly if the path points to the local filesystem. E.g.

```python
import cloudpathlib
p = cloudpathlib.AnyPath("testdir")
p.mkdir()
p.rmtree()
```

results in

```
Traceback (most recent call last):
File "/workspaces/scoutingtool/backend/test.py", line 4, in
p.rmtree()
^^^^^^^^
AttributeError: 'PosixPath' object has no attribute 'rmtree'
```

It would be nice if `AnyPath` supported `rmtree()`. The workaround is to check if the path points to the local filesystem, and then using `shutil.rmtree()` instead in that case, but that complicates the code a bit.

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.