Add type annotations for Pathlike arguments#3864
Merged
JelleZijlstra merged 4 commits intopython:masterfrom Mar 22, 2020
Merged
Add type annotations for Pathlike arguments#3864JelleZijlstra merged 4 commits intopython:masterfrom
JelleZijlstra merged 4 commits intopython:masterfrom
Conversation
JelleZijlstra
requested changes
Mar 19, 2020
stdlib/2and3/filecmp.pyi
Outdated
| shallow: Union[int, bool] = ...) -> Tuple[List[AnyStr], List[AnyStr], List[AnyStr]]: ... | ||
| if sys.version_info >= (3, 6): | ||
| def cmp(f1: Union[bytes, Text, Path], f2: Union[bytes, Text, Path], shallow: Union[int, bool] = ...) -> bool: ... | ||
| def cmpfiles(a: Union[AnyStr, Path], b: Union[AnyStr, Path], common: Iterable[AnyStr], |
Member
There was a problem hiding this comment.
This should be PathLike[AnyStr] I think, so that the str/bytes match is right even if you use PathLikes.
Though I think that may run into an annoying mypy bug.
Contributor
Author
There was a problem hiding this comment.
I am not sure pathlib.Path accepts bytes. I get this error: TypeError: argument should be a str object or an os.PathLike object returning str, not <class 'bytes'>
I have added the changes and surprisingly it didn't break anything
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.
Closes #3858