Skip to content

Fix join_path type inconsistency: return Path when Path inputs are provided#33

Merged
lfengad merged 2 commits into
NVIDIA:mainfrom
Muneerali199:fix/join-path-type-inconsistency
Jun 11, 2026
Merged

Fix join_path type inconsistency: return Path when Path inputs are provided#33
lfengad merged 2 commits into
NVIDIA:mainfrom
Muneerali199:fix/join-path-type-inconsistency

Conversation

@Muneerali199

Copy link
Copy Markdown
Contributor

Summary

LocalBackend.join_path accepted Union[str, Path] inputs but always returned str (via os.path.join), even when Path objects were passed. This violated the type contract and could cause AttributeError downstream.

Changes

  • local_backend.py: Now checks if any input is a Path and returns Path(result) accordingly. Removed the stale TODO that acknowledged this issue.
  • base_backend.py, easy_io.py, file_client.py: Updated return type from str to Union[str, Path].
  • boto3_backend.py, msc_backend.py, http_backend.py: Updated return type signature for consistency with the abstract base class.

Related Issue

Closes #32

…ovided

- LocalBackend.join_path now checks if inputs are Path and returns Path
- Updated return type hints from str to Union[str, Path] across all backends
- Updated docstrings to reflect the correct return type
- Fixes TODO in local_backend.py:210 that acknowledged this issue

@foreverlms foreverlms left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@lfengad lfengad enabled auto-merge (squash) June 11, 2026 05:33
@lfengad lfengad merged commit 016c96d into NVIDIA:main Jun 11, 2026
7 checks passed
rahul-steiger-nv pushed a commit to rahul-steiger-nv/cosmos-framework that referenced this pull request Jun 15, 2026
…ovided (NVIDIA#33)

## Summary

`LocalBackend.join_path` accepted `Union[str, Path]` inputs but always
returned `str` (via `os.path.join`), even when `Path` objects were
passed. This violated the type contract and could cause `AttributeError`
downstream.

## Changes

- **local_backend.py**: Now checks if any input is a `Path` and returns
`Path(result)` accordingly. Removed the stale TODO that acknowledged
this issue.
- **base_backend.py, easy_io.py, file_client.py**: Updated return type
from `str` to `Union[str, Path]`.
- **boto3_backend.py, msc_backend.py, http_backend.py**: Updated return
type signature for consistency with the abstract base class.

## Related Issue

Closes NVIDIA#32

Co-authored-by: Maosheng Liao <maoshengl@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Easy IO join_path silently converts Path to str, breaking type contract

3 participants