From 16f0607ed29f20c09e89f2cacc0e28e982309d60 Mon Sep 17 00:00:00 2001 From: Yobmod Date: Mon, 5 Jul 2021 12:31:00 +0100 Subject: Improve typing of config_levels, add assert_never() --- git/refs/symbolic.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git/refs') diff --git a/git/refs/symbolic.py b/git/refs/symbolic.py index ca0691d9..f0bd9316 100644 --- a/git/refs/symbolic.py +++ b/git/refs/symbolic.py @@ -1,3 +1,4 @@ +from git.types import PathLike import os from git.compat import defenc @@ -408,7 +409,7 @@ class SymbolicReference(object): return RefLog.entry_at(RefLog.path(self), index) @classmethod - def to_full_path(cls, path): + def to_full_path(cls, path) -> PathLike: """ :return: string with a full repository-relative path which can be used to initialize a Reference instance, for instance by using ``Reference.from_path``""" -- cgit v1.2.1 From c2317a768f4d6b72b9c20d4fbe455af8a0d77c36 Mon Sep 17 00:00:00 2001 From: Yobmod Date: Mon, 5 Jul 2021 18:47:44 +0100 Subject: Make bytesIO forwardref --- git/refs/head.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'git/refs') diff --git a/git/refs/head.py b/git/refs/head.py index c698004d..97c8e6a1 100644 --- a/git/refs/head.py +++ b/git/refs/head.py @@ -5,9 +5,13 @@ from git.exc import GitCommandError from .symbolic import SymbolicReference from .reference import Reference -from typing import Union +from typing import Union, TYPE_CHECKING + from git.types import Commit_ish +if TYPE_CHECKING: + from git.repo import Repo + __all__ = ["HEAD", "Head"] @@ -25,12 +29,13 @@ class HEAD(SymbolicReference): _ORIG_HEAD_NAME = 'ORIG_HEAD' __slots__ = () - def __init__(self, repo, path=_HEAD_NAME): + def __init__(self, repo: 'Repo', path=_HEAD_NAME): if path != self._HEAD_NAME: raise ValueError("HEAD instance must point to %r, got %r" % (self._HEAD_NAME, path)) super(HEAD, self).__init__(repo, path) + self.commit: 'Commit_ish' - def orig_head(self): + def orig_head(self) -> 'SymbolicReference': """ :return: SymbolicReference pointing at the ORIG_HEAD, which is maintained to contain the previous value of HEAD""" -- cgit v1.2.1