1+ from collections .abc import Iterator , Sequence
12from io import DEFAULT_BUFFER_SIZE , IOBase
23from pathlib import Path
34from queue import Queue
45from threading import Event
56from typing import (
67 Generic ,
7- Iterator ,
88 Literal ,
9- Optional ,
10- Sequence ,
11- Type ,
129 TypedDict ,
1310 TypeVar ,
1411 overload ,
@@ -303,29 +300,34 @@ class _ObjectBase(Generic[T]):
303300 name : str | None
304301 raw_name : bytes | None
305302 short_id : str
306- type : 'Literal[GIT_OBJ_COMMIT] | Literal[GIT_OBJ_TREE] | Literal[GIT_OBJ_TAG] | Literal[GIT_OBJ_BLOB]'
307- type_str : "Literal['commit'] | Literal['tree'] | Literal['tag'] | Literal['blob']"
303+ type : (
304+ Literal [GIT_OBJ_COMMIT ]
305+ | Literal [GIT_OBJ_TREE ]
306+ | Literal [GIT_OBJ_TAG ]
307+ | Literal [GIT_OBJ_BLOB ]
308+ )
309+ type_str : Literal ['commit' ] | Literal ['tree' ] | Literal ['tag' ] | Literal ['blob' ]
308310 author : Signature
309311 committer : Signature
310312 tree : Tree
311313 @overload
312314 def peel (
313- self , target_type : ' Literal[GIT_OBJ_COMMIT, ObjectType.COMMIT] | Type [Commit]'
314- ) -> ' Commit' : ...
315+ self , target_type : Literal [GIT_OBJ_COMMIT , ObjectType .COMMIT ] | type [Commit ]
316+ ) -> Commit : ...
315317 @overload
316318 def peel (
317- self , target_type : ' Literal[GIT_OBJ_TREE, ObjectType.TREE] | Type [Tree]'
318- ) -> ' Tree' : ...
319+ self , target_type : Literal [GIT_OBJ_TREE , ObjectType .TREE ] | type [Tree ]
320+ ) -> Tree : ...
319321 @overload
320322 def peel (
321- self , target_type : ' Literal[GIT_OBJ_TAG, ObjectType.TAG] | Type [Tag]'
322- ) -> ' Tag' : ...
323+ self , target_type : Literal [GIT_OBJ_TAG , ObjectType .TAG ] | type [Tag ]
324+ ) -> Tag : ...
323325 @overload
324326 def peel (
325- self , target_type : ' Literal[GIT_OBJ_BLOB, ObjectType.BLOB] | Type [Blob]'
326- ) -> ' Blob' : ...
327+ self , target_type : Literal [GIT_OBJ_BLOB , ObjectType .BLOB ] | type [Blob ]
328+ ) -> Blob : ...
327329 @overload
328- def peel (self , target_type : ' None' ) -> ' Commit| Tree| Tag| Blob' : ...
330+ def peel (self , target_type : None ) -> Commit | Tree | Tag | Blob : ...
329331 def read_raw (self ) -> bytes : ...
330332 def __eq__ (self , other ) -> bool : ...
331333 def __ge__ (self , other ) -> bool : ...
@@ -350,15 +352,15 @@ class Reference:
350352 def delete (self ) -> None : ...
351353 def log (self ) -> Iterator [RefLogEntry ]: ...
352354 @overload
353- def peel (self , type : ' Literal[GIT_OBJ_COMMIT] | Type [Commit]' ) -> ' Commit' : ...
355+ def peel (self , type : Literal [GIT_OBJ_COMMIT ] | type [Commit ]) -> Commit : ...
354356 @overload
355- def peel (self , type : ' Literal[GIT_OBJ_TREE] | Type [Tree]' ) -> ' Tree' : ...
357+ def peel (self , type : Literal [GIT_OBJ_TREE ] | type [Tree ]) -> Tree : ...
356358 @overload
357- def peel (self , type : ' Literal[GIT_OBJ_TAG] | Type [Tag]' ) -> ' Tag' : ...
359+ def peel (self , type : Literal [GIT_OBJ_TAG ] | type [Tag ]) -> Tag : ...
358360 @overload
359- def peel (self , type : ' Literal[GIT_OBJ_BLOB] | Type [Blob]' ) -> ' Blob' : ...
361+ def peel (self , type : Literal [GIT_OBJ_BLOB ] | type [Blob ]) -> Blob : ...
360362 @overload
361- def peel (self , type : ' None' = None ) -> ' Commit| Tree| Tag| Blob' : ...
363+ def peel (self , type : None = None ) -> Commit | Tree | Tag | Blob : ...
362364 def rename (self , new_name : str ) -> None : ...
363365 def resolve (self ) -> Reference : ...
364366 def set_target (self , target : _OidArg , message : str = ...) -> None : ...
@@ -384,7 +386,7 @@ class Blob(Object):
384386 ) -> Patch : ...
385387 def diff_to_buffer (
386388 self ,
387- buffer : Optional [ bytes | str ] = None ,
389+ buffer : bytes | str | None = None ,
388390 flag : DiffOption = DiffOption .NORMAL ,
389391 old_as_path : str = ...,
390392 buffer_as_path : str = ...,
@@ -395,9 +397,9 @@ class Blob(Object):
395397 ready : Event ,
396398 done : Event ,
397399 chunk_size : int = DEFAULT_BUFFER_SIZE ,
398- as_path : Optional [ str ] = None ,
400+ as_path : str | None = None ,
399401 flags : BlobFilter = BlobFilter .CHECK_FOR_BINARY ,
400- commit_id : Optional [ Oid ] = None ,
402+ commit_id : Oid | None = None ,
401403 ) -> None : ...
402404 def __buffer__ (self , flags : int ) -> memoryview : ...
403405 def __release_buffer__ (self , buffer : memoryview ) -> None : ...
@@ -411,7 +413,7 @@ class Branch(Reference):
411413 def delete (self ) -> None : ...
412414 def is_checked_out (self ) -> bool : ...
413415 def is_head (self ) -> bool : ...
414- def rename (self , name : str , force : bool = False ) -> ' Branch' : ... # type: ignore[override]
416+ def rename (self , name : str , force : bool = False ) -> Branch : ... # type: ignore[override]
415417
416418class FetchOptions :
417419 # incomplete
@@ -693,7 +695,7 @@ class Repository:
693695 def create_branch (self , name : str , commit : Commit , force = False ) -> Branch : ...
694696 def create_commit (
695697 self ,
696- reference_name : Optional [ str ] ,
698+ reference_name : str | None ,
697699 author : Signature ,
698700 committer : Signature ,
699701 message : str | bytes ,
@@ -711,7 +713,7 @@ class Repository:
711713 encoding : str = ...,
712714 ) -> Oid : ...
713715 def create_commit_with_signature (
714- self , content : str , signature : str , signature_field : Optional [ str ] = None
716+ self , content : str , signature : str , signature_field : str | None = None
715717 ) -> Oid : ...
716718 def create_note (
717719 self ,
@@ -723,10 +725,10 @@ class Repository:
723725 force : bool = False ,
724726 ) -> Oid : ...
725727 def create_reference_direct (
726- self , name : str , target : _OidArg , force : bool , message : Optional [ str ] = None
728+ self , name : str , target : _OidArg , force : bool , message : str | None = None
727729 ) -> Reference : ...
728730 def create_reference_symbolic (
729- self , name : str , target : str , force : bool , message : Optional [ str ] = None
731+ self , name : str , target : str , force : bool , message : str | None = None
730732 ) -> Reference : ...
731733 def create_tag (
732734 self , name : str , oid : _OidArg , type : ObjectType , tagger : Signature , message : str
@@ -801,7 +803,7 @@ class Signature:
801803 email : str ,
802804 time : int = - 1 ,
803805 offset : int = 0 ,
804- encoding : Optional [ str ] = None ,
806+ encoding : str | None = None ,
805807 ) -> None : ...
806808 def __eq__ (self , other ) -> bool : ...
807809 def __ge__ (self , other ) -> bool : ...
0 commit comments