Skip to content

Commit e470047

Browse files
committed
update file finding logic
1 parent 7f49299 commit e470047

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

agent/agent_utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,11 @@ def topological_sort_based_on_dependencies(pkg_paths: list[str]) -> list[str]:
216216
for path in sorted(module_set.by_path.keys()):
217217
module_name = ".".join(module_set.by_path[path].fqn)
218218
mod = module_set.by_name[module_name]
219-
imports = module_set.get_imports(mod)
220-
import_dependencies[path] = set([str(x) for x in imports])
219+
try:
220+
imports = module_set.get_imports(mod)
221+
import_dependencies[path] = set([str(x) for x in imports])
222+
except Exception:
223+
import_dependencies[path] = set()
221224

222225
import_dependencies_files = ignore_cycles(import_dependencies)
223226

@@ -236,14 +239,15 @@ def get_target_edit_files(
236239
files = _find_files_to_edit(target_dir, src_dir, test_dir)
237240
filtered_files = []
238241
for file_path in files:
239-
with open(file_path, "r", encoding="utf-8", errors="ignore") as file:
242+
with open(file_path, "r", encoding="utf-8-sig", errors="ignore") as file:
240243
content = file.read()
241244
if len(content.splitlines()) > 1500:
242245
continue
243246
if " pass" in content:
244247
filtered_files.append(file_path)
245248
# Change to reference commit to get the correct dependencies
246249
local_repo.git.checkout(reference_commit)
250+
247251
topological_sort_files = topological_sort_based_on_dependencies(filtered_files)
248252
if len(topological_sort_files) != len(filtered_files):
249253
if len(topological_sort_files) < len(filtered_files):

0 commit comments

Comments
 (0)