Skip to content

Fix Mypy typing invariance by updating List to Sequence in dataset loading functions (#5354)#8282

Open
Paramveersingh-S wants to merge 1 commit into
huggingface:mainfrom
Paramveersingh-S:main
Open

Fix Mypy typing invariance by updating List to Sequence in dataset loading functions (#5354)#8282
Paramveersingh-S wants to merge 1 commit into
huggingface:mainfrom
Paramveersingh-S:main

Conversation

@Paramveersingh-S

Copy link
Copy Markdown

Description

This PR addresses issue #5354. The standard typing.List (or built-in list) is invariant in Python, meaning static analyzers like Mypy will complain if a user tries to pass a tuple or another valid sequence into the dataset loading parameters (e.g. data_files). By refactoring these type hints from list to typing.Sequence (which is covariant) across from_csv, from_json, from_parquet, and from_text, we satisfy type checkers for read-only sequence data paths.

This change ensures cleaner integration for downstream users who use tuples or custom sequence subclasses when loading datasets.

Checklist

  • Tested locally with type hinting validation.
  • Code follows the repository's style guidelines.

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