Skip to content

Accept os.PathLike paths in every S3 filesystem method #1380

Open

Description

@laughingman7743

Part of #1341 (decision 9 of the audit).

Current state (29cc1d3)

With pathlib.Path("bucket/a"):

  1. chmod, cat_file, rm_file, touch, metadata, sign, getxattr, setxattr, get_tags, object_version_info, cp_file, list_multipart_uploads and put_file (remote path) raise TypeError: expected string or bytes-like object from S3Path.parse.
  2. rm raises TypeError: 'PosixPath' object is not iterable.
  3. glob raises AttributeError (endswith).
  4. info, exists, ls, find, du, size and checksum work, through fsspec's _strip_protocol, which calls stringify_path.

Decision

Every public method of S3FileSystem and AioS3FileSystem converts an os.PathLike path with fsspec.utils.stringify_path before it classifies the path: rm's iterable check, glob, and the pairing's isinstance(..., str) decisions included. Slashes are not stripped by the conversion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions