@@ -367,7 +367,6 @@ def ls(
367
367
"""
368
368
resolved_path = self .resolve_path (path , revision = revision )
369
369
path = resolved_path .unresolve ()
370
- kwargs = {"expand_info" : detail , ** kwargs }
371
370
try :
372
371
out = self ._ls_tree (path , refresh = refresh , revision = revision , ** kwargs )
373
372
except EntryNotFoundError :
@@ -386,7 +385,7 @@ def _ls_tree(
386
385
recursive : bool = False ,
387
386
refresh : bool = False ,
388
387
revision : Optional [str ] = None ,
389
- expand_info : bool = True ,
388
+ expand_info : bool = False ,
390
389
):
391
390
resolved_path = self .resolve_path (path , revision = revision )
392
391
path = resolved_path .unresolve ()
@@ -497,8 +496,6 @@ def walk(self, path: str, *args, **kwargs) -> Iterator[Tuple[str, List[str], Lis
497
496
Returns:
498
497
`Iterator[Tuple[str, List[str], List[str]]]`: An iterator of (path, list of directory names, list of file names) tuples.
499
498
"""
500
- # Set expand_info=False by default to get a x10 speed boost
501
- kwargs = {"expand_info" : kwargs .get ("detail" , False ), ** kwargs }
502
499
path = self .resolve_path (path , revision = kwargs .get ("revision" )).unresolve ()
503
500
yield from super ().walk (path , * args , ** kwargs )
504
501
@@ -515,8 +512,6 @@ def glob(self, path: str, **kwargs) -> List[str]:
515
512
Returns:
516
513
`List[str]`: List of paths matching the pattern.
517
514
"""
518
- # Set expand_info=False by default to get a x10 speed boost
519
- kwargs = {"expand_info" : kwargs .get ("detail" , False ), ** kwargs }
520
515
path = self .resolve_path (path , revision = kwargs .get ("revision" )).unresolve ()
521
516
return super ().glob (path , ** kwargs )
522
517
@@ -558,7 +553,6 @@ def find(
558
553
)
559
554
resolved_path = self .resolve_path (path , revision = revision )
560
555
path = resolved_path .unresolve ()
561
- kwargs = {"expand_info" : detail , ** kwargs }
562
556
try :
563
557
out = self ._ls_tree (path , recursive = True , refresh = refresh , revision = resolved_path .revision , ** kwargs )
564
558
except EntryNotFoundError :
@@ -653,7 +647,7 @@ def modified(self, path: str, **kwargs) -> datetime:
653
647
Returns:
654
648
`datetime`: Last commit date of the file.
655
649
"""
656
- info = self .info (path , ** kwargs )
650
+ info = self .info (path , ** { ** kwargs , "expand_info" : True } )
657
651
return info ["last_commit" ]["date" ]
658
652
659
653
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,
683
677
resolved_path = self .resolve_path (path , revision = revision )
684
678
path = resolved_path .unresolve ()
685
679
expand_info = kwargs .get (
686
- "expand_info" , True
680
+ "expand_info" , False
687
681
) # don't expose it as a parameter in the public API to follow the spec
688
682
if not resolved_path .path_in_repo :
689
683
# Path is the root directory
690
684
out = {
691
685
"name" : path ,
692
686
"size" : 0 ,
693
687
"type" : "directory" ,
688
+ "last_commit" : None ,
694
689
}
695
690
if expand_info :
696
691
last_commit = self ._api .list_repo_commits (
@@ -708,7 +703,7 @@ def info(self, path: str, refresh: bool = False, revision: Optional[str] = None,
708
703
parent_path = self ._parent (path )
709
704
if not expand_info and parent_path not in self .dircache :
710
705
# Fill the cache with cheap call
711
- self .ls (parent_path , expand_info = False )
706
+ self .ls (parent_path )
712
707
if parent_path in self .dircache :
713
708
# Check if the path is in the cache
714
709
out1 = [o for o in self .dircache [parent_path ] if o ["name" ] == path ]
@@ -779,7 +774,7 @@ def exists(self, path, **kwargs):
779
774
if kwargs .get ("refresh" , False ):
780
775
self .invalidate_cache (path )
781
776
782
- self .info (path , ** { ** kwargs , "expand_info" : False } )
777
+ self .info (path , ** kwargs )
783
778
return True
784
779
except : # noqa: E722
785
780
return False
@@ -798,7 +793,7 @@ def isdir(self, path):
798
793
`bool`: True if path is a directory, False otherwise.
799
794
"""
800
795
try :
801
- return self .info (path , expand_info = False )["type" ] == "directory"
796
+ return self .info (path )["type" ] == "directory"
802
797
except OSError :
803
798
return False
804
799
@@ -816,7 +811,7 @@ def isfile(self, path):
816
811
`bool`: True if path is a file, False otherwise.
817
812
"""
818
813
try :
819
- return self .info (path , expand_info = False )["type" ] == "file"
814
+ return self .info (path )["type" ] == "file"
820
815
except : # noqa: E722
821
816
return False
822
817
@@ -942,9 +937,6 @@ def __init__(self, fs: HfFileSystem, path: str, revision: Optional[str] = None,
942
937
f"{ e } .\n Make sure the repository and revision exist before writing data."
943
938
) from e
944
939
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 )
948
940
super ().__init__ (fs , self .resolved_path .unresolve (), ** kwargs )
949
941
self .fs : HfFileSystem
950
942
0 commit comments