File tree Expand file tree Collapse file tree 2 files changed +17
-11
lines changed Expand file tree Collapse file tree 2 files changed +17
-11
lines changed Original file line number Diff line number Diff line change 11from  pathlib  import  Path 
22
3- path_type_labels  =  {
4-     ' is_dir'  : 'directory' ,
5-     ' is_file'  : 'file' ,
6-     ' is_mount'  : 'mount point' ,
7-     ' is_symlink'  : 'symlink' ,
8-     ' is_block_device'  : 'block device' ,
9-     ' is_char_device'  : 'char device' ,
10-     ' is_fifo'  : 'FIFO' ,
11-     ' is_socket'  : 'socket' ,
3+ _PATH_TYPE_LABELS  =  {
4+     Path . is_dir : 'directory' ,
5+     Path . is_file : 'file' ,
6+     Path . is_mount : 'mount point' ,
7+     Path . is_symlink : 'symlink' ,
8+     Path . is_block_device : 'block device' ,
9+     Path . is_char_device : 'char device' ,
10+     Path . is_fifo : 'FIFO' ,
11+     Path . is_socket : 'socket' ,
1212}
1313
1414
@@ -17,8 +17,8 @@ def path_type_label(p: Path) -> str:
1717    Find out what sort of thing a path is. 
1818    """ 
1919    assert  p .exists (), 'path does not exist' 
20-     for  method , name  in  path_type_labels .items ():
21-         if  getattr ( p ,  method )( ):
20+     for  method , name  in  _PATH_TYPE_LABELS .items ():
21+         if  method ( p ):
2222            return  name 
2323
2424    return  'unknown' 
Original file line number Diff line number Diff line change 1+ from  pydantic_settings .utils  import  path_type_label 
2+ 
3+ 
4+ def  test_path_type_label (tmp_path ):
5+     result  =  path_type_label (tmp_path )
6+     assert  result  ==  'directory' 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments