Skip to content

mypy fixes5 #1403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ warn_unused_configs = True
warn_redundant_casts = True
warn_unused_ignores = True
no_implicit_reexport = True
disallow_subclassing_any = True
disallow_untyped_decorators = True

[mypy-test.*]
disallow_untyped_defs = True
Expand Down
13 changes: 8 additions & 5 deletions pygit2/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
from collections.abc import Callable, Generator
from contextlib import contextmanager
from functools import wraps
from typing import TYPE_CHECKING, Optional
from typing import TYPE_CHECKING, Optional, ParamSpec, TypeVar

# pygit2
from ._pygit2 import DiffFile, Oid
Expand Down Expand Up @@ -490,8 +490,11 @@ def git_remote_callbacks(payload):
# exception.
#

P = ParamSpec('P')
T = TypeVar('T')

def libgit2_callback(f):

def libgit2_callback(f: Callable[P, T]) -> Callable[P, T]:
@wraps(f)
def wrapper(*args):
data = ffi.from_handle(args[-1])
Expand All @@ -509,10 +512,10 @@ def wrapper(*args):
data._stored_exception = e
return C.GIT_EUSER

return ffi.def_extern()(wrapper)
return ffi.def_extern()(wrapper) # type: ignore[attr-defined]


def libgit2_callback_void(f):
def libgit2_callback_void(f: Callable[P, T]) -> Callable[P, T]:
@wraps(f)
def wrapper(*args):
data = ffi.from_handle(args[-1])
Expand All @@ -529,7 +532,7 @@ def wrapper(*args):
data._stored_exception = e
pass # Function returns void, so we can't do much here.

return ffi.def_extern()(wrapper)
return ffi.def_extern()(wrapper) # type: ignore[attr-defined]


@libgit2_callback
Expand Down
Loading