66
66
from collections .abc import Callable , Generator
67
67
from contextlib import contextmanager
68
68
from functools import wraps
69
- from typing import TYPE_CHECKING , Optional
69
+ from typing import TYPE_CHECKING , Optional , ParamSpec , TypeVar
70
70
71
71
# pygit2
72
72
from ._pygit2 import DiffFile , Oid
@@ -490,8 +490,11 @@ def git_remote_callbacks(payload):
490
490
# exception.
491
491
#
492
492
493
+ P = ParamSpec ('P' )
494
+ T = TypeVar ('T' )
493
495
494
- def libgit2_callback (f ):
496
+
497
+ def libgit2_callback (f : Callable [P , T ]) -> Callable [P , T ]:
495
498
@wraps (f )
496
499
def wrapper (* args ):
497
500
data = ffi .from_handle (args [- 1 ])
@@ -509,10 +512,10 @@ def wrapper(*args):
509
512
data ._stored_exception = e
510
513
return C .GIT_EUSER
511
514
512
- return ffi .def_extern ()(wrapper )
515
+ return ffi .def_extern ()(wrapper ) # type: ignore[attr-defined]
513
516
514
517
515
- def libgit2_callback_void (f ) :
518
+ def libgit2_callback_void (f : Callable [ P , T ]) -> Callable [ P , T ] :
516
519
@wraps (f )
517
520
def wrapper (* args ):
518
521
data = ffi .from_handle (args [- 1 ])
@@ -529,7 +532,7 @@ def wrapper(*args):
529
532
data ._stored_exception = e
530
533
pass # Function returns void, so we can't do much here.
531
534
532
- return ffi .def_extern ()(wrapper )
535
+ return ffi .def_extern ()(wrapper ) # type: ignore[attr-defined]
533
536
534
537
535
538
@libgit2_callback
0 commit comments