1
+ from collections .abc import Iterator , Sequence
1
2
from io import DEFAULT_BUFFER_SIZE , IOBase
2
3
from pathlib import Path
3
4
from queue import Queue
4
5
from threading import Event
5
6
from typing import (
6
7
Generic ,
7
- Iterator ,
8
8
Literal ,
9
- Optional ,
10
- Sequence ,
11
- Type ,
12
9
TypedDict ,
13
10
TypeVar ,
14
11
overload ,
@@ -303,29 +300,34 @@ class _ObjectBase(Generic[T]):
303
300
name : str | None
304
301
raw_name : bytes | None
305
302
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' ]
308
310
author : Signature
309
311
committer : Signature
310
312
tree : Tree
311
313
@overload
312
314
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 : ...
315
317
@overload
316
318
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 : ...
319
321
@overload
320
322
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 : ...
323
325
@overload
324
326
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 : ...
327
329
@overload
328
- def peel (self , target_type : ' None' ) -> ' Commit| Tree| Tag| Blob' : ...
330
+ def peel (self , target_type : None ) -> Commit | Tree | Tag | Blob : ...
329
331
def read_raw (self ) -> bytes : ...
330
332
def __eq__ (self , other ) -> bool : ...
331
333
def __ge__ (self , other ) -> bool : ...
@@ -350,15 +352,15 @@ class Reference:
350
352
def delete (self ) -> None : ...
351
353
def log (self ) -> Iterator [RefLogEntry ]: ...
352
354
@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 : ...
354
356
@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 : ...
356
358
@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 : ...
358
360
@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 : ...
360
362
@overload
361
- def peel (self , type : ' None' = None ) -> ' Commit| Tree| Tag| Blob' : ...
363
+ def peel (self , type : None = None ) -> Commit | Tree | Tag | Blob : ...
362
364
def rename (self , new_name : str ) -> None : ...
363
365
def resolve (self ) -> Reference : ...
364
366
def set_target (self , target : _OidArg , message : str = ...) -> None : ...
@@ -384,7 +386,7 @@ class Blob(Object):
384
386
) -> Patch : ...
385
387
def diff_to_buffer (
386
388
self ,
387
- buffer : Optional [ bytes | str ] = None ,
389
+ buffer : bytes | str | None = None ,
388
390
flag : DiffOption = DiffOption .NORMAL ,
389
391
old_as_path : str = ...,
390
392
buffer_as_path : str = ...,
@@ -395,9 +397,9 @@ class Blob(Object):
395
397
ready : Event ,
396
398
done : Event ,
397
399
chunk_size : int = DEFAULT_BUFFER_SIZE ,
398
- as_path : Optional [ str ] = None ,
400
+ as_path : str | None = None ,
399
401
flags : BlobFilter = BlobFilter .CHECK_FOR_BINARY ,
400
- commit_id : Optional [ Oid ] = None ,
402
+ commit_id : Oid | None = None ,
401
403
) -> None : ...
402
404
def __buffer__ (self , flags : int ) -> memoryview : ...
403
405
def __release_buffer__ (self , buffer : memoryview ) -> None : ...
@@ -411,7 +413,7 @@ class Branch(Reference):
411
413
def delete (self ) -> None : ...
412
414
def is_checked_out (self ) -> bool : ...
413
415
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]
415
417
416
418
class FetchOptions :
417
419
# incomplete
@@ -693,7 +695,7 @@ class Repository:
693
695
def create_branch (self , name : str , commit : Commit , force = False ) -> Branch : ...
694
696
def create_commit (
695
697
self ,
696
- reference_name : Optional [ str ] ,
698
+ reference_name : str | None ,
697
699
author : Signature ,
698
700
committer : Signature ,
699
701
message : str | bytes ,
@@ -711,7 +713,7 @@ class Repository:
711
713
encoding : str = ...,
712
714
) -> Oid : ...
713
715
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
715
717
) -> Oid : ...
716
718
def create_note (
717
719
self ,
@@ -723,10 +725,10 @@ class Repository:
723
725
force : bool = False ,
724
726
) -> Oid : ...
725
727
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
727
729
) -> Reference : ...
728
730
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
730
732
) -> Reference : ...
731
733
def create_tag (
732
734
self , name : str , oid : _OidArg , type : ObjectType , tagger : Signature , message : str
@@ -801,7 +803,7 @@ class Signature:
801
803
email : str ,
802
804
time : int = - 1 ,
803
805
offset : int = 0 ,
804
- encoding : Optional [ str ] = None ,
806
+ encoding : str | None = None ,
805
807
) -> None : ...
806
808
def __eq__ (self , other ) -> bool : ...
807
809
def __ge__ (self , other ) -> bool : ...
0 commit comments