#!/usr/bin/env python3 """Count Python files in directory tree recursively.""" import sys from pathlib import Path def count_py_files(directory: str = ".") -> int: """Count Python files in directory tree.""" return len(list(Path(directory).rglob("*.py"))) if __name__ == "__main__": target = sys.argv[1] if len(sys.argv) > 1 else "." print(count_py_files(target))