Skip to content
Merged
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ include README.md
include VERSION
include requirements.txt
include test-requirements.txt
include git/py.typed

recursive-include doc *
recursive-exclude test *
Expand Down
4 changes: 2 additions & 2 deletions git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,11 @@ def polish_url(cls, url: str, is_cygwin: Literal[False] = ...) -> str:

@overload
@classmethod
def polish_url(cls, url: PathLike, is_cygwin: Union[None, bool] = None) -> str:
def polish_url(cls, url: str, is_cygwin: Union[None, bool] = None) -> str:
...

@classmethod
def polish_url(cls, url: PathLike, is_cygwin: Union[None, bool] = None) -> PathLike:
def polish_url(cls, url: str, is_cygwin: Union[None, bool] = None) -> PathLike:
if is_cygwin is None:
is_cygwin = cls.is_cygwin()

Expand Down
14 changes: 11 additions & 3 deletions git/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

import configparser as cp

from pathlib import Path

# typing-------------------------------------------------------

from typing import Any, Callable, IO, List, Dict, Sequence, TYPE_CHECKING, Tuple, Union, cast, overload
Expand Down Expand Up @@ -330,7 +328,7 @@ def _acquire_lock(self) -> None:
"Write-ConfigParsers can operate on a single file only, multiple files have been passed")
# END single file check

if isinstance(self._file_or_files, (str, Path)): # cannot narrow by os._pathlike until 3.5 dropped
if isinstance(self._file_or_files, (str, os.PathLike)):
file_or_files = self._file_or_files
else:
file_or_files = cast(IO, self._file_or_files).name
Expand Down Expand Up @@ -696,6 +694,16 @@ def read_only(self) -> bool:
""":return: True if this instance may change the configuration file"""
return self._read_only

@overload
def get_value(self, section: str, option: str, default: str
) -> str:
...

@overload
def get_value(self, section: str, option: str, default: float
) -> float:
...

def get_value(self, section: str, option: str, default: Union[int, float, str, bool, None] = None
) -> Union[int, float, str, bool]:
# can default or return type include bool?
Expand Down
10 changes: 6 additions & 4 deletions git/index/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
from git.refs.reference import Reference

import glob
from io import BytesIO
import os
Expand Down Expand Up @@ -74,6 +74,8 @@
if TYPE_CHECKING:
from subprocess import Popen
from git.repo import Repo
from git.refs.reference import Reference
from git.util import Actor


StageType = int
Expand Down Expand Up @@ -966,8 +968,8 @@ def move(self, items: Sequence[Union[PathLike, Blob, BaseIndexEntry, Submodule]]

return out

def commit(self, message: str, parent_commits=None, head: bool = True, author: str = None,
committer: str = None, author_date: str = None, commit_date: str = None,
def commit(self, message: str, parent_commits=None, head: bool = True, author: Union[None, 'Actor'] = None,
committer: Union[None, 'Actor'] = None, author_date: str = None, commit_date: str = None,
skip_hooks: bool = False) -> Commit:
"""Commit the current default index file, creating a commit object.
For more information on the arguments, see tree.commit.
Expand Down Expand Up @@ -1191,7 +1193,7 @@ def handle_stderr(proc: 'Popen[bytes]', iter_checked_out_files: Iterable[PathLik
assert "Should not reach this point"

@default_index
def reset(self, commit: Union[Commit, Reference, str] = 'HEAD', working_tree: bool = False,
def reset(self, commit: Union[Commit, 'Reference', str] = 'HEAD', working_tree: bool = False,
paths: Union[None, Iterable[PathLike]] = None,
head: bool = False, **kwargs: Any) -> 'IndexFile':
"""Reset the index to reflect the tree at the given commit. This will not
Expand Down
9 changes: 5 additions & 4 deletions git/objects/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@

from typing import Any, TYPE_CHECKING, Optional, Union

from git.types import PathLike
from git.types import PathLike, Commit_ish

if TYPE_CHECKING:
from git.repo import Repo
from gitdb.base import OStream
from .tree import Tree
from .blob import Blob
from .tag import TagObject
from .commit import Commit
from .submodule.base import Submodule

IndexObjUnion = Union['Tree', 'Blob', 'Submodule']

# --------------------------------------------------------------------------

Expand Down Expand Up @@ -71,7 +72,7 @@ def new(cls, repo: 'Repo', id): # @ReservedAssignment
return repo.rev_parse(str(id))

@classmethod
def new_from_sha(cls, repo: 'Repo', sha1: bytes) -> Union['Commit', 'TagObject', 'Tree', 'Blob']:
def new_from_sha(cls, repo: 'Repo', sha1: bytes) -> Commit_ish:
"""
:return: new object instance of a type appropriate to represent the given
binary sha1
Expand Down
Loading