9
9
from ..util import hex_to_bin
10
10
from ..compat import defenc
11
11
12
+ from typing import List , TYPE_CHECKING , Union
13
+
14
+ if TYPE_CHECKING :
15
+ from git .repo import Repo
16
+ from git .util import Actor
17
+
12
18
__all__ = ("TagObject" , )
13
19
14
20
@@ -18,8 +24,10 @@ class TagObject(base.Object):
18
24
type = "tag"
19
25
__slots__ = ("object" , "tag" , "tagger" , "tagged_date" , "tagger_tz_offset" , "message" )
20
26
21
- def __init__ (self , repo , binsha , object = None , tag = None , # @ReservedAssignment
22
- tagger = None , tagged_date = None , tagger_tz_offset = None , message = None ):
27
+ def __init__ (self , repo : 'Repo' , binsha : bytes , object : Union [None , base .Object ] = None ,
28
+ tag : Union [None , str ] = None , tagger : Union [None , Actor ] = None , tagged_date : Union [int , None ] = None ,
29
+ tagger_tz_offset : Union [int , None ] = None , message : Union [str , None ] = None
30
+ ) -> None : # @ReservedAssignment
23
31
"""Initialize a tag object with additional data
24
32
25
33
:param repo: repository this object is located in
@@ -46,11 +54,11 @@ def __init__(self, repo, binsha, object=None, tag=None, # @ReservedAssignment
46
54
if message is not None :
47
55
self .message = message
48
56
49
- def _set_cache_ (self , attr ) :
57
+ def _set_cache_ (self , attr : str ) -> None :
50
58
"""Cache all our attributes at once"""
51
59
if attr in TagObject .__slots__ :
52
60
ostream = self .repo .odb .stream (self .binsha )
53
- lines = ostream .read ().decode (defenc , 'replace' ).splitlines ()
61
+ lines = ostream .read ().decode (defenc , 'replace' ).splitlines () # type: List[str]
54
62
55
63
_obj , hexsha = lines [0 ].split (" " )
56
64
_type_token , type_name = lines [1 ].split (" " )
0 commit comments