Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3347c00
change ordereddict guard, add type: ignore
Yobmod Jul 28, 2021
77a7769
Merge branch 'main' of https://github.com/Yobmod/GitPython
Yobmod Jul 28, 2021
28fdd30
Fix SymbolicReference reference typing
Yobmod Jul 28, 2021
3abc837
Add another type ignore for Ordereddict
Yobmod Jul 28, 2021
6791424
Rmv py 3.10 check for typing.Ordereddict - its deprecated then, but w…
Yobmod Jul 28, 2021
c464e33
Fix some SymbolicReference types
Yobmod Jul 28, 2021
7cf30c1
Fix forwardref
Yobmod Jul 28, 2021
5b880c0
Fix more missing types in Symbolic.py
Yobmod Jul 28, 2021
07d71e5
Fix more missing types in Symbolic.py
Yobmod Jul 28, 2021
b8b07b9
Fix more missing types in Symbolic.py.
Yobmod Jul 28, 2021
390efbf
Fix more missing types in Symbolic.py, cos GuthubActions pytest stuck
Yobmod Jul 28, 2021
070f5c0
Rmv test file
Yobmod Jul 28, 2021
adc00dd
Fix more missing types in Symbolic.py, cos GuthubActions pytest stuck
Yobmod Jul 28, 2021
28251c3
Try downgrading pip
Yobmod Jul 28, 2021
dbb689b
its not pip...
Yobmod Jul 28, 2021
cf29514
try https://github.com/actions/virtual-environments/issues/709 workar…
Yobmod Jul 28, 2021
f1e6e8d
Merge branch 'main' of https://github.com/Yobmod/GitPython
Yobmod Jul 31, 2021
15d1c01
Add type to symbolicreference.name()
Yobmod Jul 31, 2021
34e9850
Add type to symbolicreference.iter_items()
Yobmod Jul 31, 2021
265d40b
Add type to symbolicreference.rename()
Yobmod Jul 31, 2021
bdd6a43
Add type to symbolicreference.__repr__()
Yobmod Jul 31, 2021
1f92267
Add type to symbolicreference._get_ref_info()
Yobmod Jul 31, 2021
ad4517f
Add type to symbolicreference._get_packed_refs_path()
Yobmod Jul 31, 2021
6b0faba
Add type to symbolicreference.dereference_recursive()
Yobmod Jul 31, 2021
7e972b9
Add type to symbolicreference.dereference_recursive()
Yobmod Jul 31, 2021
24c1242
Add type to symbolicreference()
Yobmod Jul 31, 2021
8eedc9d
Add type to symbolicreference.get_()
Yobmod Jul 31, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add type to symbolicreference.rename()
  • Loading branch information
Yobmod committed Jul 31, 2021
commit 265d40be3cf0e6f16d7ffd22f5fbd4a503f09219
13 changes: 7 additions & 6 deletions git/refs/symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

if TYPE_CHECKING:
from git.repo import Repo
from git.refs import Head, TagReference, Reference

T_References = TypeVar('T_References', bound='SymbolicReference')

Expand Down Expand Up @@ -59,10 +60,10 @@ class SymbolicReference(object):

def __init__(self, repo: 'Repo', path: PathLike, check_path: bool = False):
self.repo = repo
self.path = str(path)
self.path = path

def __str__(self) -> str:
return self.path
return str(self.path)

def __repr__(self):
return '<git.%s "%s">' % (self.__class__.__name__, self.path)
Expand All @@ -84,7 +85,7 @@ def name(self) -> str:
:return:
In case of symbolic references, the shortest assumable name
is the path itself."""
return self.path
return str(self.path)

@property
def abspath(self) -> PathLike:
Expand Down Expand Up @@ -557,7 +558,7 @@ def create(cls, repo: 'Repo', path: PathLike, reference: Union[Commit_ish, str]
:note: This does not alter the current HEAD, index or Working Tree"""
return cls._create(repo, path, cls._resolve_ref_on_create, reference, force, logmsg)

def rename(self, new_path, force=False):
def rename(self, new_path: PathLike, force: bool = False) -> 'SymbolicReference':
"""Rename self to a new path

:param new_path:
Expand All @@ -577,7 +578,7 @@ def rename(self, new_path, force=False):

new_abs_path = os.path.join(_git_dir(self.repo, new_path), new_path)
cur_abs_path = os.path.join(_git_dir(self.repo, self.path), self.path)
if os.path.path.isfile(new_abs_path):
if os.path.isfile(new_abs_path):
if not force:
# if they point to the same file, its not an error
with open(new_abs_path, 'rb') as fd1:
Expand Down Expand Up @@ -663,7 +664,7 @@ def iter_items(cls: Type[T_References], repo: 'Repo', common_path: Union[PathLik
return (r for r in cls._iter_items(repo, common_path) if r.__class__ == SymbolicReference or not r.is_detached)

@classmethod
def from_path(cls, repo, path):
def from_path(cls, repo: 'Repo', path: PathLike) -> Union['Head', 'TagReference', 'Reference']:
"""
:param path: full .git-directory-relative path name to the Reference to instantiate
:note: use to_full_path() if you only have a partial path of a known Reference Type
Expand Down