summaryrefslogtreecommitdiff
path: root/git/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'git/util.py')
-rw-r--r--git/util.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/git/util.py b/git/util.py
index 76ac92f1..d1ea4c10 100644
--- a/git/util.py
+++ b/git/util.py
@@ -374,18 +374,31 @@ def get_user_id() -> str:
return "%s@%s" % (getpass.getuser(), platform.node())
-def finalize_process(proc: TBD, **kwargs: Any) -> None:
+def finalize_process(proc: subprocess.Popen, **kwargs: Any) -> None:
"""Wait for the process (clone, fetch, pull or push) and handle its errors accordingly"""
## TODO: No close proc-streams??
proc.wait(**kwargs)
-def expand_path(p: PathLike, expand_vars: bool = True) -> Optional[PathLike]:
+@overload
+def expand_path(p: None, expand_vars: bool = ...) -> None:
+ ...
+
+
+@overload
+def expand_path(p: PathLike, expand_vars: bool = ...) -> str:
+ ...
+
+
+def expand_path(p: Union[None, PathLike], expand_vars: bool = True) -> Optional[str]:
try:
- p = osp.expanduser(p)
- if expand_vars:
- p = osp.expandvars(p)
- return osp.normpath(osp.abspath(p))
+ if p is not None:
+ p_out = osp.expanduser(p)
+ if expand_vars:
+ p_out = osp.expandvars(p_out)
+ return osp.normpath(osp.abspath(p_out))
+ else:
+ return None
except Exception:
return None