Skip to content
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
1 change: 1 addition & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"stubs/psycopg2",
"stubs/pyasn1",
"stubs/pyflakes",
"stubs/pygit2",
"stubs/Pygments",
"stubs/PyMySQL",
"stubs/python-dateutil",
Expand Down
17 changes: 17 additions & 0 deletions stubs/pygit2/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# stubtest wrongly checks the Python implementation with the cffi type's
# stubs, likely due to name shadowing that happens at import-time
pygit2.Repository.__init__
pygit2.Repository._from_c
# @cached_property that fail to get recognized as such by stubtest
pygit2.config.ConfigEntry.level
pygit2.config.ConfigEntry.raw_name
pygit2.config.ConfigEntry.raw_value
# Actual signatures enforced by C-level checks not visible to stubtest
pygit2.Mailmap.__init__
pygit2.OdbBackend.__init__
pygit2.RefLogEntry.__init__
pygit2.RefdbBackend.__init__
pygit2._pygit2.Mailmap.__init__
pygit2._pygit2.OdbBackend.__init__
pygit2._pygit2.RefLogEntry.__init__
pygit2._pygit2.RefdbBackend.__init__
6 changes: 6 additions & 0 deletions stubs/pygit2/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version = "1.14.*"
upstream_repository = "https://github.com/libgit2/pygit2"
requires = ["types-cffi"]

[tool.stubtest]
platforms = ["darwin", "linux", "win32"]
54 changes: 54 additions & 0 deletions stubs/pygit2/pygit2/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from _typeshed import StrOrBytesPath, SupportsAllComparisons
from collections.abc import Callable

from . import enums
from ._build import __version__ as __version__
from ._pygit2 import *
from .blame import Blame as Blame, BlameHunk as BlameHunk
from .blob import BlobIO as BlobIO
from .callbacks import (
CheckoutCallbacks as CheckoutCallbacks,
Payload as Payload,
RemoteCallbacks,
StashApplyCallbacks as StashApplyCallbacks,
get_credentials as get_credentials,
)
from .config import Config as Config
from .credentials import *
from .errors import Passthrough as Passthrough
from .filter import Filter as Filter
from .index import Index as Index, IndexEntry as IndexEntry
from .legacyenums import *
from .packbuilder import PackBuilder as PackBuilder
from .remotes import Remote as Remote
from .repository import Repository # type: ignore[assignment]
from .settings import Settings
from .submodules import Submodule as Submodule

features: enums.Feature
LIBGIT2_VER: tuple[int, int, int]

def init_repository(
path: StrOrBytesPath | None,
bare: bool = False,
flags: enums.RepositoryInitFlag = ...,
mode: int | enums.RepositoryInitMode = ...,
workdir_path: str | None = None,
description: str | None = None,
template_path: str | None = None,
initial_head: str | None = None,
origin_url: str | None = None,
) -> Repository: ...
def clone_repository(
url: str,
path: str,
bare: bool = False,
repository: Callable[[str, bool], Repository] | None = None,
remote: Callable[[Repository, str, str], Remote] | None = None,
checkout_branch: str | None = None,
callbacks: RemoteCallbacks | None = None,
depth: int = 0,
) -> Repository: ...

tree_entry_key: Callable[[Object], SupportsAllComparisons] # functools.cmp_to_key(tree_entry_cmp)
settings: Settings
5 changes: 5 additions & 0 deletions stubs/pygit2/pygit2/_build.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from pathlib import Path

__version__: str

def get_libgit2_paths() -> tuple[Path, dict[str, list[str]]]: ...
4 changes: 4 additions & 0 deletions stubs/pygit2/pygit2/_libgit2.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from _cffi_backend import FFI, Lib

ffi: FFI
lib: Lib
Loading