Skip to content

Commit

Permalink
Move the abstract methods to a single location.
Browse files Browse the repository at this point in the history
  • Loading branch information
asnare committed Jul 16, 2024
1 parent f5bb6b9 commit 29913b0
Showing 1 changed file with 46 additions and 46 deletions.
92 changes: 46 additions & 46 deletions src/databricks/labs/blueprint/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,52 @@ def _splitroot(cls, part: str, sep: str) -> tuple[str, str]:
return sep, part.lstrip(sep)
return "", part

@abstractmethod
def as_uri(self) -> str: ...

@abstractmethod
def as_fuse(self) -> Path: ...

@abstractmethod
def exists(self, *, follow_symlinks: bool = True) -> bool: ...

@abstractmethod
def mkdir(self, mode: int = 0o600, parents: bool = True, exist_ok: bool = True) -> None: ...

@abstractmethod
def rmdir(self, recursive: bool = False) -> None: ...

@abstractmethod
def unlink(self, missing_ok: bool = False) -> None: ...

@abstractmethod
def open(
self,
mode: str = "r",
buffering: int = -1,
encoding: str | None = None,
errors: str | None = None,
newline: str | None = None,
): ...

@abstractmethod
def is_dir(self) -> bool: ...

@abstractmethod
def is_file(self) -> bool: ...

@abstractmethod
def rename(self: P, target: str | bytes | os.PathLike) -> P: ...

@abstractmethod
def replace(self: P, target: str | bytes | os.PathLike) -> P: ...

@abstractmethod
def expanduser(self: P) -> P: ...

@abstractmethod
def iterdir(self: P) -> Generator[P, None, None]: ...

def __reduce__(self) -> NoReturn:
# Cannot support pickling because we can't pickle the workspace client.
msg = f"Pickling {self.__class__.__qualname__} paths is not supported."
Expand Down Expand Up @@ -445,12 +491,6 @@ def home(self): # pylint: disable=arguments-differ
"""Return the user's home directory. Adapted from pathlib.Path"""
return type(self)(self._ws, "~").expanduser()

@abstractmethod
def rename(self: P, target: str | bytes | os.PathLike) -> P: ...

@abstractmethod
def replace(self: P, target: str | bytes | os.PathLike) -> P: ...

def _return_false(self) -> bool:
return False

Expand Down Expand Up @@ -514,46 +554,6 @@ def rglob(
selector = _Selector.parse(pattern_parts, case_sensitive=case_sensitive)
yield from selector(self)

@abstractmethod
def as_uri(self) -> str: ...

@abstractmethod
def as_fuse(self) -> Path: ...

@abstractmethod
def exists(self, *, follow_symlinks: bool = True) -> bool: ...

@abstractmethod
def mkdir(self, mode: int = 0o600, parents: bool = True, exist_ok: bool = True) -> None: ...

@abstractmethod
def rmdir(self, recursive: bool = False) -> None: ...

@abstractmethod
def unlink(self, missing_ok: bool = False) -> None: ...

@abstractmethod
def open(
self,
mode: str = "r",
buffering: int = -1,
encoding: str | None = None,
errors: str | None = None,
newline: str | None = None,
): ...

@abstractmethod
def is_dir(self) -> bool: ...

@abstractmethod
def is_file(self) -> bool: ...

@abstractmethod
def expanduser(self: P) -> P: ...

@abstractmethod
def iterdir(self: P) -> Generator[P, None, None]: ...


class DBFSPath(_DatabricksPath):
"""Experimental implementation of pathlib.Path for DBFS paths."""
Expand Down

0 comments on commit 29913b0

Please sign in to comment.