-
Notifications
You must be signed in to change notification settings - Fork 13
refactor uses of UPath #693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
if (path / "header.wkw").is_file(): | ||
header_path = path / "header.wkw" | ||
|
||
if header_path.exists() and header_path.is_file(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a fix for a bug that @leowe found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One might argue that this is also a bug in UPath, but always sending two requests for the is_file check also seems wrong. In any case the fix is good atm!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I already have a fix for UPath in the pipeline.
def make_upath(maybe_path: Union[str, PathLike, Path]) -> UPath: | ||
return maybe_path if isinstance(maybe_path, UPath) else UPath(maybe_path) | ||
|
||
|
||
def is_fs_path(path: Path) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could get rid of this as well, but I actually think is_fs_path
is more expressive than not isinstance(path, UPath)
.
@normanrz Is this PR ready for review? |
Yes! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, LGTM 👌
Now that fsspec/universal_pathlib#56, fsspec/universal_pathlib#53 and fsspec/universal_pathlib#52 are merged, we can simplify our code a bit.