Skip to content

Standardize path handling throughout the code base #6814

Open
@GeigerJ2

Description

@GeigerJ2

As discussed with @edan-bainglass.

In PR #6255, an inconsistency in the type handling of the filepath_executable of PortableCode was identified by the introduction of pydantic (see here for reference).

Looking throughout the code base, we have two different type aliases for path-like types:

TransportPath = Union[str, Path, PurePosixPath]

FilePath = Union[str, pathlib.PurePath]

FilePath also here:
FilePath = t.Union[str, pathlib.PurePath]

FilePath = t.Union[str, pathlib.PurePath]

As well as standard type hints for paths, and combinations of the two:

def copy_tree(self, target: Union[str, pathlib.Path], path: Optional[FilePath] = None) -> None:

While I wouldn't deem this super high priority, it might be useful to standardize those path-like annotations if possible, or at least put them in a dedicated module, e.g., aiida/common/types.py. Also, many (probably older) parts of the codebase use os.path (this is especially prevalent in the transport plugins), where we could also consider switching to pathlib at some point.

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