-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlint_python_scripts.py
More file actions
executable file
·36 lines (30 loc) · 939 Bytes
/
Copy pathlint_python_scripts.py
File metadata and controls
executable file
·36 lines (30 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python3
"""
This script is designed to lint all Python scripts in the current directory and
its subdirectories using pylint.
"""
GREEN = "\033[0;32m"
RED = "\033[0;31m"
INFO = "\033[0;34m"
RESET = "\033[0m"
if __name__ == "__main__":
from pathlib import Path
import subprocess
summary = {"successful": 0, "failed": 0}
for path in Path('.').rglob('*.py'):
print(path.name)
try:
print(f"{INFO}Linting {path}...")
result = subprocess.run(['pylint', str(path)], check=True)
if result.returncode == 0:
summary["successful"] += 1
else:
summary["failed"] += 1
except subprocess.CalledProcessError:
summary["failed"] += 1
print(f"{RESET}")
print(f"""
Linting completed.
{GREEN}Successful: {summary['successful']}{RESET}
{RED}Failed: {summary['failed']}{RESET}
""")