@@ -1129,22 +1129,23 @@ def find_imports(cls, file_path):
1129
1129
"""
1130
1130
import ast
1131
1131
1132
- file_text = open (file_path ).read ()
1133
- # Parse the file to get the abstract syntax tree representation
1134
- tree = ast .parse (file_text )
1135
- modules = []
1136
-
1137
- # Walk through each node in the ast to find import calls
1138
- for node in ast .walk (tree ):
1139
- # Determine parent module for from * import * calls
1140
- if isinstance (node , ast .ImportFrom ):
1141
- for name in node .names :
1142
- if not name .asname :
1143
- modules .append (node .module )
1144
- elif isinstance (node , ast .Import ):
1145
- for name in node .names :
1146
- if not node .names [0 ].asname :
1147
- modules .append (node .names [0 ].name )
1132
+ with open (file_path , "r" ) as file :
1133
+ file_text = file .read ()
1134
+ # Parse the file to get the abstract syntax tree representation
1135
+ tree = ast .parse (file_text )
1136
+ modules = []
1137
+
1138
+ # Walk through each node in the ast to find import calls
1139
+ for node in ast .walk (tree ):
1140
+ # Determine parent module for from * import * calls
1141
+ if isinstance (node , ast .ImportFrom ):
1142
+ for name in node .names :
1143
+ if not name .asname :
1144
+ modules .append (node .module )
1145
+ elif isinstance (node , ast .Import ):
1146
+ for name in node .names :
1147
+ if not node .names [0 ].asname :
1148
+ modules .append (node .names [0 ].name )
1148
1149
1149
1150
modules = list (set (modules ))
1150
1151
try :
@@ -1169,10 +1170,7 @@ def get_pickle_file(cls, pickle_folder=Path.cwd()):
1169
1170
list
1170
1171
A list of pickle files.
1171
1172
"""
1172
-
1173
- file_names = []
1174
- file_names .extend (sorted (Path (pickle_folder ).glob ("*.pickle" )))
1175
- return file_names
1173
+ return [p for p in Path (pickle_folder ).iterdir () if p .suffix in [".pickle" , ".pkl" ]]
1176
1174
1177
1175
@classmethod
1178
1176
def get_pickle_dependencies (cls , pickle_file ):
0 commit comments