Skip to content

fix #5354#8334

Open
wasim-builds wants to merge 1 commit into
huggingface:mainfrom
wasim-builds:fix-first-issue
Open

fix #5354#8334
wasim-builds wants to merge 1 commit into
huggingface:mainfrom
wasim-builds:fix-first-issue

Conversation

@wasim-builds

Copy link
Copy Markdown

This PR updates the type hint for the path_or_paths argument in dataset loading methods (from_parquet, from_csv, from_json, and from_text) in src/datasets/arrow_dataset.py.

It replaces list[PathLike] with Sequence[PathLike]. Since list is invariant and Sequence is covariant, this prevents users from receiving false-positive type checking errors (like with mypy) when passing lists of specific types (like List[str]).

Checklist

  • I have read the CONTRIBUTING.md file.
  • I have run make style to format my code.

Copilot AI review requested due to automatic review settings July 15, 2026 06:14
@wasim-builds wasim-builds reopened this Jul 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the static type hints for dataset loading entry points in arrow_dataset.py by widening path_or_paths from an invariant list[...] to a covariant Sequence[...], reducing false-positive type-checker errors for users (e.g., when passing List[str]).

Changes:

  • Update path_or_paths annotations in Dataset.from_csv, Dataset.from_json, Dataset.from_parquet, and Dataset.from_text from list[PathLike] to Sequence_[PathLike].
  • Keep the API surface the same at runtime while improving typing ergonomics for callers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@staticmethod
def from_csv(
path_or_paths: Union[PathLike, list[PathLike]],
path_or_paths: Union[PathLike, Sequence_[PathLike]],
@staticmethod
def from_json(
path_or_paths: Union[PathLike, list[PathLike]],
path_or_paths: Union[PathLike, Sequence_[PathLike]],
@staticmethod
def from_parquet(
path_or_paths: Union[PathLike, list[PathLike]],
path_or_paths: Union[PathLike, Sequence_[PathLike]],
@staticmethod
def from_text(
path_or_paths: Union[PathLike, list[PathLike]],
path_or_paths: Union[PathLike, Sequence_[PathLike]],
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.

2 participants