Skip to content

Make BIDSPath support os.PathLike protocol #1525

@skjerns

Description

@skjerns

As per documentation, BIDSPath is already closely related to pathlib.Path and inherently represents a path

BIDSPath allows dynamic updating of its entities in place, and operates similar to pathlib.Path.

As it is not recognized as a Path or os.PathLike, many libraries do not accept it as an argument for a filepath (e.g. see joblib/joblib#1784). It might be useful to indicate to other libraries "this is a Path!".

I understand that subtyping pathlib.Path might not be a good idea, so maybe implementing os.PathLike protocol to indicate to other libraries "Hey, this is a path!"? Or is there a reason not to do that?

apparently, this is as simple as

def __fspath__(self):
    return str(self.fpath)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions