Skip to content

Commit

Permalink
Cleanup pathlib references
Browse files Browse the repository at this point in the history
  • Loading branch information
brl0 committed May 9, 2023
1 parent 0c6b9e1 commit 1957849
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions upath/core.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from __future__ import annotations

import pathlib
import re
import sys
from collections import ChainMap
from os import PathLike
from pathlib import _PosixFlavour # type: ignore
from pathlib import Path
from pathlib import PurePath
from typing import Sequence
from typing import TypeVar
Expand Down Expand Up @@ -132,7 +132,7 @@ def splitroot(self, part, sep="/"):
PT = TypeVar("PT", bound="UPath")


class UPath(pathlib.Path):
class UPath(Path):
__slots__ = (
"_url",
"_kwargs",
Expand All @@ -154,7 +154,7 @@ def __new__(cls: type[PT], *args: str | PathLike, **kwargs: Any) -> PT:
args_list = list(args)
other = args_list.pop(0)

if isinstance(other, pathlib.Path):
if isinstance(other, PurePath):
# Create a (modified) copy, if first arg is a Path object
_cls: type[Any] = type(other)
drv, root, parts = _cls._parse_args(args_list)
Expand Down Expand Up @@ -182,9 +182,9 @@ def __new__(cls: type[PT], *args: str | PathLike, **kwargs: Any) -> PT:
parsed_url = parsed_url._replace(**{key: val})

upath_cls = get_upath_class(protocol=parsed_url.scheme)
if upath_cls in {pathlib.Path, None}:
if upath_cls in {Path, None}:
# treat as local filesystem, return PosixPath or WindowsPath
return pathlib.Path(*args, **kwargs) # type: ignore
return Path(*args, **kwargs) # type: ignore

args_list.insert(0, parsed_url.path)
# return upath instance
Expand Down

0 comments on commit 1957849

Please sign in to comment.