fix #5354#8334
Open
wasim-builds wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
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_pathsannotations inDataset.from_csv,Dataset.from_json,Dataset.from_parquet, andDataset.from_textfromlist[PathLike]toSequence_[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]], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR updates the type hint for the
path_or_pathsargument in dataset loading methods (from_parquet,from_csv,from_json, andfrom_text) insrc/datasets/arrow_dataset.py.It replaces
list[PathLike]withSequence[PathLike]. Sincelistis invariant andSequenceis covariant, this prevents users from receiving false-positive type checking errors (like withmypy) when passing lists of specific types (likeList[str]).Checklist
CONTRIBUTING.mdfile.make styleto format my code.