refactor: update filter_important_files to use global IMPORTANT_FILES list

This commit is contained in:
Paul Gauthier (aider) 2024-08-30 14:35:02 -07:00
parent e629971138
commit 2cb13b5ebb

View file

@ -62,6 +62,13 @@ IMPORTANT_FILES = [
"CODEOWNERS", ".pypirc",
]
def filter_important_files(file_paths):
"""
Filter a list of file paths to return only those that are commonly important in codebases.
:param file_paths: List of file paths to check
:return: List of file paths that match important file patterns
"""
def is_important(file_path):
file_name = os.path.basename(file_path)
dir_name = os.path.dirname(file_path)
@ -82,8 +89,8 @@ IMPORTANT_FILES = [
if file_name == "migrations" and os.path.isdir(file_path):
return True
return file_name in important_files or any(
file_path.endswith(f"/{name}") for name in important_files
return file_name in IMPORTANT_FILES or any(
file_path.endswith(f"/{name}") for name in IMPORTANT_FILES
)
return list(filter(is_important, file_paths))