1- """Module containing util"""
1+ """Module containing util. """
22import argparse
3- import os
43import stat
54import subprocess
65from pathlib import Path
1110class MissingDependencyError (Exception ):
1211 """Exception raised when a depedency is missing from the system running setup-repo."""
1312 def __init__ (self , project : Path , dependency : str ):
13+ """Initializes MisssingDependencyError."""
1414 super ().__init__ ("\n " .join ([
1515 f"Unable to find { dependency = } ." ,
1616 f"Please ensure that { dependency } is installed before setting up the repo at { project .absolute ()} "
@@ -22,8 +22,8 @@ def check_dependencies(path: Path, dependencies: list[str]) -> None:
2222 for dependency in dependencies :
2323 try :
2424 subprocess .check_call ([dependency , "--version" ], cwd = path )
25- except subprocess .CalledProcessError :
26- raise MissingDependencyError (path , dependency )
25+ except subprocess .CalledProcessError as e :
26+ raise MissingDependencyError (path , dependency ) from e
2727
2828
2929def existing_dir (value : str ) -> Path :
@@ -43,5 +43,5 @@ def remove_readonly(func: Callable[[str], Any], path: str, _: Any) -> None:
4343
4444 This is passed to shutil.rmtree as the onerror kwarg.
4545 """
46- os .chmod (path , stat .S_IWRITE )
46+ Path ( path ) .chmod (stat .S_IWRITE )
4747 func (path )
0 commit comments