Find all Python files in the given directory. Args: directory: The directory to search for Python files. exclude_dirs: List of directory names to exclude from the search. Returns: A list of paths to Python files.
(
directory: str, exclude_dirs: Optional[List[str]] = None
)
| 17 | |
| 18 | |
| 19 | def find_python_files( |
| 20 | directory: str, exclude_dirs: Optional[List[str]] = None |
| 21 | ) -> List[str]: |
| 22 | """Find all Python files in the given directory. |
| 23 | |
| 24 | Args: |
| 25 | directory: The directory to search for Python files. |
| 26 | exclude_dirs: List of directory names to exclude from the search. |
| 27 | |
| 28 | Returns: |
| 29 | A list of paths to Python files. |
| 30 | """ |
| 31 | if exclude_dirs is None: |
| 32 | exclude_dirs = [] |
| 33 | |
| 34 | exclude_set = set(exclude_dirs) |
| 35 | python_files = [] |
| 36 | |
| 37 | for root, dirs, files in os.walk(directory): |
| 38 | # Skip excluded directories |
| 39 | dirs[:] = [d for d in dirs if d not in exclude_set] |
| 40 | |
| 41 | for file in files: |
| 42 | if file.endswith(".py"): |
| 43 | python_files.append(os.path.join(root, file)) |
| 44 | |
| 45 | return python_files |
| 46 | |
| 47 | |
| 48 | def run_pycodestyle(paths: List[str], exclude: Optional[List[str]] = None) -> str: |