You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Traceback (most recent call last):
File "/workspaces/scoutingtool/backend/test.py", line 4, in <module>
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.
The text was updated successfully, but these errors were encountered:
@parviste We've got an open feature request to have a clutil model that implements the shutil methods and handles both CloudPath and Path scenarios. #189
Would something like that work for you?
Since AnyPath just dispatches to a Path or CloudPath instance, I think that will be the cleanest implementation. The only other option would be patching the built in Path objects to have some of these shared utility methods with CloudPath, which is not preferred.
I think having something like clutil would work, but in that case it would IMHO be a good idea to deprecate any functionality in CloudPath (e.g. rmtree) that is not in Path, to really make it possible to use AnyPath as mostly a drop-in replacement for CloudPath.
I'm using
cloudpathlib.AnyPath
to be able to fall back to a local filesystem for e.g. testing. However, it seems thatAnyPath.rmtree()
does not work correctly if the path points to the local filesystem. E.g.results in
It would be nice if
AnyPath
supportedrmtree()
. The workaround is to check if the path points to the local filesystem, and then usingshutil.rmtree()
instead in that case, but that complicates the code a bit.The text was updated successfully, but these errors were encountered: