Skip to content

exists should work on a bucket #291

@mjkanji

Description

@mjkanji

CloudPath currently doesn't let you easily check if a bucket itself exists. The exists method only works if you provide some path inside the bucket. This is a nice feature in Pathy and the analogous equivalent of pathlib.Path also works. It would be great to have this included in this library as well.

from pathy import Pathy
from cloudpathlib import CloudPath
from pathlib import Path

# Doesn't work
CloudPath("s3://some-bucket/").exists()
# ParamValidationError: Parameter validation failed:
# Invalid length for parameter Key, value: 0, valid min length: 1

Pathy("s3://some-bucket/").exists() # True

# Since a bucket is the equivalent of a drive, a comparison to pathlib.Path 
# for checking if a drive exists (I'm using Windows)
 Path("C:").exists() # True

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions