summaryrefslogtreecommitdiff
path: root/git/util.py
diff options
context:
space:
mode:
authorSebastian Thiel <sebastian.thiel@icloud.com>2021-05-18 08:29:52 +0800
committerGitHub <noreply@github.com>2021-05-18 08:29:52 +0800
commitb11bcfa3df4d0b792823930bffae126fd12673f7 (patch)
tree85dc837ef6cadec84d232f5e7110d2dfc44c3b1a /git/util.py
parent33346b25c3a4fb5ea37202d88d6a6c66379099c5 (diff)
parentc30bf3ba7548a0e996907b9a097ec322760eb43a (diff)
downloadgitpython-b11bcfa3df4d0b792823930bffae126fd12673f7.tar.gz
Merge pull request #1244 from Yobmod/main
Added types to Index submodule
Diffstat (limited to 'git/util.py')
-rw-r--r--git/util.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/git/util.py b/git/util.py
index 220901a4..76aaee49 100644
--- a/git/util.py
+++ b/git/util.py
@@ -24,6 +24,7 @@ from urllib.parse import urlsplit, urlunsplit
from typing import (Any, AnyStr, BinaryIO, Callable, Dict, Generator, IO, Iterator, List,
Optional, Pattern, Sequence, Tuple, Union, cast, TYPE_CHECKING, overload)
+import pathlib
if TYPE_CHECKING:
from git.remote import Remote
@@ -376,10 +377,13 @@ def expand_path(p: None, expand_vars: bool = ...) -> None:
@overload
def expand_path(p: PathLike, expand_vars: bool = ...) -> str:
+ # improve these overloads when 3.5 dropped
...
-def expand_path(p: Union[None, PathLike], expand_vars: bool = True) -> Optional[str]:
+def expand_path(p: Union[None, PathLike], expand_vars: bool = True) -> Optional[PathLike]:
+ if isinstance(p, pathlib.Path):
+ return p.resolve()
try:
p = osp.expanduser(p) # type: ignore
if expand_vars: