6666from collections .abc import Callable , Generator
6767from contextlib import contextmanager
6868from functools import wraps
69- from typing import TYPE_CHECKING , Optional
69+ from typing import TYPE_CHECKING , Optional , ParamSpec , TypeVar
7070
7171# pygit2
7272from ._pygit2 import DiffFile , Oid
@@ -490,8 +490,11 @@ def git_remote_callbacks(payload):
490490# exception.
491491#
492492
493+ P = ParamSpec ('P' )
494+ T = TypeVar ('T' )
493495
494- def libgit2_callback (f ):
496+
497+ def libgit2_callback (f : Callable [P , T ]) -> Callable [P , T ]:
495498 @wraps (f )
496499 def wrapper (* args ):
497500 data = ffi .from_handle (args [- 1 ])
@@ -509,10 +512,10 @@ def wrapper(*args):
509512 data ._stored_exception = e
510513 return C .GIT_EUSER
511514
512- return ffi .def_extern ()(wrapper )
515+ return ffi .def_extern ()(wrapper ) # type: ignore[attr-defined]
513516
514517
515- def libgit2_callback_void (f ) :
518+ def libgit2_callback_void (f : Callable [ P , T ]) -> Callable [ P , T ] :
516519 @wraps (f )
517520 def wrapper (* args ):
518521 data = ffi .from_handle (args [- 1 ])
@@ -529,7 +532,7 @@ def wrapper(*args):
529532 data ._stored_exception = e
530533 pass # Function returns void, so we can't do much here.
531534
532- return ffi .def_extern ()(wrapper )
535+ return ffi .def_extern ()(wrapper ) # type: ignore[attr-defined]
533536
534537
535538@libgit2_callback
0 commit comments