@@ -367,7 +367,6 @@ def ls(
367367 """
368368 resolved_path = self .resolve_path (path , revision = revision )
369369 path = resolved_path .unresolve ()
370- kwargs = {"expand_info" : detail , ** kwargs }
371370 try :
372371 out = self ._ls_tree (path , refresh = refresh , revision = revision , ** kwargs )
373372 except EntryNotFoundError :
@@ -386,7 +385,7 @@ def _ls_tree(
386385 recursive : bool = False ,
387386 refresh : bool = False ,
388387 revision : Optional [str ] = None ,
389- expand_info : bool = True ,
388+ expand_info : bool = False ,
390389 ):
391390 resolved_path = self .resolve_path (path , revision = revision )
392391 path = resolved_path .unresolve ()
@@ -497,8 +496,6 @@ def walk(self, path: str, *args, **kwargs) -> Iterator[Tuple[str, List[str], Lis
497496 Returns:
498497 `Iterator[Tuple[str, List[str], List[str]]]`: An iterator of (path, list of directory names, list of file names) tuples.
499498 """
500- # Set expand_info=False by default to get a x10 speed boost
501- kwargs = {"expand_info" : kwargs .get ("detail" , False ), ** kwargs }
502499 path = self .resolve_path (path , revision = kwargs .get ("revision" )).unresolve ()
503500 yield from super ().walk (path , * args , ** kwargs )
504501
@@ -515,8 +512,6 @@ def glob(self, path: str, **kwargs) -> List[str]:
515512 Returns:
516513 `List[str]`: List of paths matching the pattern.
517514 """
518- # Set expand_info=False by default to get a x10 speed boost
519- kwargs = {"expand_info" : kwargs .get ("detail" , False ), ** kwargs }
520515 path = self .resolve_path (path , revision = kwargs .get ("revision" )).unresolve ()
521516 return super ().glob (path , ** kwargs )
522517
@@ -558,7 +553,6 @@ def find(
558553 )
559554 resolved_path = self .resolve_path (path , revision = revision )
560555 path = resolved_path .unresolve ()
561- kwargs = {"expand_info" : detail , ** kwargs }
562556 try :
563557 out = self ._ls_tree (path , recursive = True , refresh = refresh , revision = resolved_path .revision , ** kwargs )
564558 except EntryNotFoundError :
@@ -653,7 +647,7 @@ def modified(self, path: str, **kwargs) -> datetime:
653647 Returns:
654648 `datetime`: Last commit date of the file.
655649 """
656- info = self .info (path , ** kwargs )
650+ info = self .info (path , ** { ** kwargs , "expand_info" : True } )
657651 return info ["last_commit" ]["date" ]
658652
659653 def info (self , path : str , refresh : bool = False , revision : Optional [str ] = None , ** kwargs ) -> Dict [str , Any ]:
@@ -683,14 +677,15 @@ def info(self, path: str, refresh: bool = False, revision: Optional[str] = None,
683677 resolved_path = self .resolve_path (path , revision = revision )
684678 path = resolved_path .unresolve ()
685679 expand_info = kwargs .get (
686- "expand_info" , True
680+ "expand_info" , False
687681 ) # don't expose it as a parameter in the public API to follow the spec
688682 if not resolved_path .path_in_repo :
689683 # Path is the root directory
690684 out = {
691685 "name" : path ,
692686 "size" : 0 ,
693687 "type" : "directory" ,
688+ "last_commit" : None ,
694689 }
695690 if expand_info :
696691 last_commit = self ._api .list_repo_commits (
@@ -708,7 +703,7 @@ def info(self, path: str, refresh: bool = False, revision: Optional[str] = None,
708703 parent_path = self ._parent (path )
709704 if not expand_info and parent_path not in self .dircache :
710705 # Fill the cache with cheap call
711- self .ls (parent_path , expand_info = False )
706+ self .ls (parent_path )
712707 if parent_path in self .dircache :
713708 # Check if the path is in the cache
714709 out1 = [o for o in self .dircache [parent_path ] if o ["name" ] == path ]
@@ -779,7 +774,7 @@ def exists(self, path, **kwargs):
779774 if kwargs .get ("refresh" , False ):
780775 self .invalidate_cache (path )
781776
782- self .info (path , ** { ** kwargs , "expand_info" : False } )
777+ self .info (path , ** kwargs )
783778 return True
784779 except : # noqa: E722
785780 return False
@@ -798,7 +793,7 @@ def isdir(self, path):
798793 `bool`: True if path is a directory, False otherwise.
799794 """
800795 try :
801- return self .info (path , expand_info = False )["type" ] == "directory"
796+ return self .info (path )["type" ] == "directory"
802797 except OSError :
803798 return False
804799
@@ -816,7 +811,7 @@ def isfile(self, path):
816811 `bool`: True if path is a file, False otherwise.
817812 """
818813 try :
819- return self .info (path , expand_info = False )["type" ] == "file"
814+ return self .info (path )["type" ] == "file"
820815 except : # noqa: E722
821816 return False
822817
@@ -942,9 +937,6 @@ def __init__(self, fs: HfFileSystem, path: str, revision: Optional[str] = None,
942937 f"{ e } .\n Make sure the repository and revision exist before writing data."
943938 ) from e
944939 raise
945- # avoid an unnecessary .info() call with expensive expand_info=True to instantiate .details
946- if kwargs .get ("mode" , "rb" ) == "rb" :
947- self .details = fs .info (self .resolved_path .unresolve (), expand_info = False )
948940 super ().__init__ (fs , self .resolved_path .unresolve (), ** kwargs )
949941 self .fs : HfFileSystem
950942
0 commit comments