1111import posixpath
1212import re
1313import shutil
14+ import stat
1415from abc import abstractmethod
1516from collections .abc import Generator , Iterable , Sequence
1617from io import BytesIO , StringIO
@@ -121,7 +122,6 @@ class _DatabricksPath(Path, abc.ABC): # pylint: disable=too-many-public-methods
121122 # Public APIs that we don't support.
122123 as_uri = _na ("as_uri" )
123124 cwd = _na ("cwd" )
124- stat = _na ("stat" )
125125 chmod = _na ("chmod" )
126126 lchmod = _na ("lchmod" )
127127 lstat = _na ("lstat" )
@@ -138,6 +138,7 @@ def __new__(cls, *args, **kwargs):
138138 # Force all initialisation to go via __init__() irrespective of the (Python-specific) base version.
139139 return object .__new__ (cls )
140140
141+ # pylint: disable=super-init-not-called
141142 def __init__ (self , ws : WorkspaceClient , * args : str | bytes | os .PathLike ) -> None :
142143 # We deliberately do _not_ call the super initializer because we're taking over complete responsibility for the
143144 # implementation of the public API.
@@ -385,6 +386,7 @@ def with_suffix(self: P, suffix: str) -> P:
385386 raise ValueError (msg )
386387 return self .with_name (stem + suffix )
387388
389+ # pylint: disable=arguments-differ
388390 def relative_to (self : P , * other : str | bytes | os .PathLike , walk_up : bool = False ) -> P :
389391 normalized = self .with_segments (* other )
390392 if self .anchor != normalized .anchor :
@@ -691,6 +693,14 @@ def _file_info(self) -> FileInfo:
691693 self ._cached_file_info = self ._ws .dbfs .get_status (self .as_posix ())
692694 return self ._cached_file_info
693695
696+ def stat (self , * , follow_symlinks = True ) -> os .stat_result :
697+ seq : list [float ] = [- 1.0 ] * 10
698+ seq [stat .ST_SIZE ] = self ._file_info .file_size or - 1 # 6
699+ seq [stat .ST_MTIME ] = (
700+ float (self ._file_info .modification_time ) / 1000.0 if self ._file_info .modification_time else - 1.0
701+ ) # 8
702+ return os .stat_result (seq )
703+
694704 def is_dir (self ) -> bool :
695705 """Return True if the path points to a DBFS directory."""
696706 try :
@@ -841,6 +851,15 @@ def _object_info(self) -> ObjectInfo:
841851 self ._cached_object_info = self ._ws .workspace .get_status (self .as_posix ())
842852 return self ._object_info
843853
854+ def stat (self , * , follow_symlinks = True ) -> os .stat_result :
855+ seq : list [float ] = [- 1.0 ] * 10
856+ seq [stat .ST_SIZE ] = self ._object_info .size or - 1 # 6
857+ seq [stat .ST_MTIME ] = (
858+ float (self ._object_info .modified_at ) / 1000.0 if self ._object_info .modified_at else - 1.0
859+ ) # 8
860+ seq [stat .ST_CTIME ] = float (self ._object_info .created_at ) / 1000.0 if self ._object_info .created_at else - 1.0 # 9
861+ return os .stat_result (seq )
862+
844863 def is_dir (self ) -> bool :
845864 """Return True if the path points to a directory in Databricks Workspace."""
846865 try :
0 commit comments