diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2021-05-18 08:29:52 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-18 08:29:52 +0800 |
commit | b11bcfa3df4d0b792823930bffae126fd12673f7 (patch) | |
tree | 85dc837ef6cadec84d232f5e7110d2dfc44c3b1a /git/util.py | |
parent | 33346b25c3a4fb5ea37202d88d6a6c66379099c5 (diff) | |
parent | c30bf3ba7548a0e996907b9a097ec322760eb43a (diff) | |
download | gitpython-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.py | 6 |
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: |