Skip to content

Use Sequence instead of list in Dataset.from_parquet type hints#7962

Open
Mukundtimbadiya20 wants to merge 3 commits intohuggingface:mainfrom
Mukundtimbadiya20:fix-sequence-type
Open

Use Sequence instead of list in Dataset.from_parquet type hints#7962
Mukundtimbadiya20 wants to merge 3 commits intohuggingface:mainfrom
Mukundtimbadiya20:fix-sequence-type

Conversation

@Mukundtimbadiya20
Copy link

This PR updates type annotations in Dataset.from_parquet to use Sequence instead of list to avoid mypy invariant type issues, as discussed in issue #5354.

Updated type annotations to avoid mypy invariant List issues.
Copilot AI review requested due to automatic review settings January 26, 2026 17:01
Copy link

Copilot AI left a comment

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 attempts to fix mypy invariant type issues by updating type annotations in Dataset.from_parquet from list to Sequence, as discussed in issue #5354. However, the implementation contains critical errors that break backward compatibility.

Changes:

  • Added import for Sequence from typing module
  • Changed path_or_paths parameter type annotation from Union[PathLike, list[PathLike]] to Sequence[Union[PathLike, Sequence[PathLike]]]
  • Changed columns parameter type annotation from Optional[list[str]] to Optional[Sequence[str]]

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

Use collections.abc.Sequence and restore Union[PathLike, Sequence[PathLike]] signature.
@Mukundtimbadiya20
Copy link
Author

Thank you for the review!

I’ve updated the implementation to:

  • Use Sequence from collections.abc as per project conventions
  • Restore backward compatibility with Union[PathLike, Sequence[PathLike]]
  • Keep the columns annotation as Optional[Sequence[str]]

The fixes are pushed. Please let me know if anything else is needed.

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.

1 participant