|
53 | 53 |
|
54 | 54 | fromtypingimport (Dict,IO,List,Sequence,TYPE_CHECKING,Tuple,Type,Union,cast)
|
55 | 55 |
|
56 |
| -fromgit.typesimportPathLike |
| 56 | +fromgit.typesimportPathLike,TypeGuard |
57 | 57 |
|
58 | 58 | ifTYPE_CHECKING:
|
59 | 59 | from .baseimportIndexFile
|
@@ -185,11 +185,17 @@ def read_header(stream: IO[bytes]) -> Tuple[int, int]:
|
185 | 185 | defentry_key(*entry:Union[BaseIndexEntry,PathLike,int])->Tuple[PathLike,int]:
|
186 | 186 | """:return: Key suitable to be used for the index.entries dictionary
|
187 | 187 | :param entry: One instance of type BaseIndexEntry or the path and the stage"""
|
| 188 | + |
| 189 | +defis_entry_tuple(entry:Tuple)->TypeGuard[Tuple[PathLike,int]]: |
| 190 | +returnisinstance(entry,tuple)andlen(entry)==2 |
| 191 | + |
188 | 192 | iflen(entry)==1:
|
189 |
| -entry_first=cast(BaseIndexEntry,entry[0])# type: BaseIndexEntry |
| 193 | +entry_first=entry[0] |
| 194 | +assertisinstance(entry_first,BaseIndexEntry) |
190 | 195 | return (entry_first.path,entry_first.stage)
|
191 | 196 | else:
|
192 |
| -entry=cast(Tuple[PathLike,int],tuple(entry)) |
| 197 | +# entry = tuple(entry) |
| 198 | +assertis_entry_tuple(entry) |
193 | 199 | returnentry
|
194 | 200 | # END handle entry
|
195 | 201 |
|
|