Created
December 31, 2024 16:17
-
-
Save JoneSabino/4f69907cdb121a35a0907c6ba80a2e35 to your computer and use it in GitHub Desktop.
Runs vulture without failing the hook or pipeline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Run Vulture to find dead code.""" | |
import subprocess | |
import sys | |
def run_vulture() -> None: | |
"""Run Vulture to find dead code.""" | |
try: | |
process = subprocess.Popen( | |
[ | |
"vulture", | |
"src", | |
"tests", | |
"--min-confidence=60", | |
"--exclude=.venv,.git,.mypy_cache,.pytest_cache,.trunk,.vscode,.idea,output,temp", | |
], | |
stdout=subprocess.PIPE, | |
stderr=subprocess.PIPE, | |
text=True, | |
) | |
if not process.stdout or not process.stderr: | |
print("Error running Vulture", file=sys.stderr) | |
sys.exit(1) | |
for line in process.stdout: | |
sys.stdout.write(line) | |
for line in process.stderr: | |
sys.stderr.write(line) | |
process.wait() | |
sys.exit(0) | |
except Exception as e: | |
print(f"Error running Vulture: {e}", file=sys.stderr) | |
raise e | |
if __name__ == "__main__": | |
run_vulture() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment