Get all ignore files that match any of the user-defined ignore paths
(repo_root: Path, ignore_paths: List[str])
| 68 | |
| 69 | |
| 70 | def get_ignore_files(repo_root: Path, ignore_paths: List[str]) -> Set[Path]: |
| 71 | """Get all ignore files that match any of the user-defined ignore paths""" |
| 72 | ignore_files = set() |
| 73 | for ignore_path in set(ignore_paths): |
| 74 | # ignore_path may contains matchers (* or **). Use glob() to match user-defined path to actual paths |
| 75 | for matched_path in repo_root.glob(ignore_path): |
| 76 | if matched_path.is_file(): |
| 77 | # If the matched path is a file, add that to ignore_files set |
| 78 | ignore_files.add(matched_path.resolve()) |
| 79 | else: |
| 80 | # Otherwise, list all Python files in that directory and add all of them to ignore_files set |
| 81 | ignore_files |= { |
| 82 | sub_path.resolve() |
| 83 | for sub_path in matched_path.glob("**/*.py") |
| 84 | if sub_path.is_file() |
| 85 | } |
| 86 | return ignore_files |
| 87 | |
| 88 | |
| 89 | def get_repo_files(repo_root: Path) -> List[Path]: |