From f96eb0cdaeb6e33bf7725e1fb0385509f6030969 Mon Sep 17 00:00:00 2001 From: Patrick Massot Date: Mon, 24 Jun 2024 14:02:53 -0400 Subject: [PATCH] Change aliases to work around mypy issue. Fixes #1934 Note this should also gives better LSP support to these property aliases. --- git/remote.py | 11 +++++++++-- git/repo/base.py | 24 ++++++++++++++++++++---- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/git/remote.py b/git/remote.py index 37c991d27..15e360064 100644 --- a/git/remote.py +++ b/git/remote.py @@ -828,8 +828,15 @@ def remove(cls, repo: "Repo", name: str) -> str: name._clear_cache() return name - # `rm` is an alias. - rm = remove + @classmethod + def rm(cls, repo: "Repo", name: str) -> str: + """Alias of remove. + Remove the remote with the given name. + + :return: + The passed remote name to remove + """ + return cls.remove(repo, name) def rename(self, new_name: str) -> "Remote": """Rename self to the given `new_name`. diff --git a/git/repo/base.py b/git/repo/base.py index 51ea76901..346248ddb 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -402,6 +402,17 @@ def heads(self) -> "IterableList[Head]": """ return Head.list_items(self) + @property + def branches(self) -> "IterableList[Head]": + """Alias for heads. + A list of :class:`~git.refs.head.Head` objects representing the branch heads + in this repo. + + :return: + ``git.IterableList(Head, ...)`` + """ + return self.heads + @property def references(self) -> "IterableList[Reference]": """A list of :class:`~git.refs.reference.Reference` objects representing tags, @@ -412,11 +423,16 @@ def references(self) -> "IterableList[Reference]": """ return Reference.list_items(self) - # Alias for references. - refs = references + @property + def refs(self) -> "IterableList[Reference]": + """Alias for references. + A list of :class:`~git.refs.reference.Reference` objects representing tags, + heads and remote references. - # Alias for heads. - branches = heads + :return: + ``git.IterableList(Reference, ...)`` + """ + return self.references @property def index(self) -> "IndexFile":