diff --git a/.gitignore b/.gitignore index 37c1e9c..94e914b 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ test_binary workflow *.pyz orbiter-* +.python-version diff --git a/orbiter/rules/rulesets.py b/orbiter/rules/rulesets.py index c2ae14b..aba7cbe 100644 --- a/orbiter/rules/rulesets.py +++ b/orbiter/rules/rulesets.py @@ -751,7 +751,17 @@ def get_files_with_extension(self, input_dir: Path) -> Generator[Path, dict]: extensions.append(f".{other_extension}") logger.debug(f"Finding files with extension={extensions} in {input_dir}") - for directory, _, files in input_dir.walk(): + + def backport_walk(input_dir: Path): + """Path.walk() is only available in Python 3.12+, so, backport""" + import os + + for result in os.walk(input_dir): + yield Path(result[0]), result[1], result[2] + + for directory, _, files in ( + input_dir.walk() if hasattr(input_dir, "walk") else backport_walk(input_dir) + ): logger.debug(f"Checking directory={directory}") for file in files: file = directory / file