Skip to content

Commit 0ad1501

Browse files
authored
pygit2: Workaround python/mypy#16972 (#11584)
To fix the signatures of `clone_repository` and `init_repository` as seen by type checkers.
1 parent ff7caa3 commit 0ad1501

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

stubs/pygit2/@tests/stubtest_allowlist.txt

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# stubtest wrongly checks the Python implementation with the cffi type's
2-
# stubs, likely due to name shadowing that happens at import-time
3-
pygit2.Repository.__init__
4-
pygit2.Repository._from_c
51
# @cached_property that fail to get recognized as such by stubtest
62
pygit2.config.ConfigEntry.level
73
pygit2.config.ConfigEntry.raw_name

stubs/pygit2/pygit2/__init__.pyi

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
from _typeshed import StrOrBytesPath, SupportsAllComparisons
22
from collections.abc import Callable
33

4+
# This is intentionally duplicated and placed above the _pygit2
5+
# star-import to workaround mypy issue #16972, so that consumers
6+
# of the stubs see the correct, wrapped type for the name
7+
# "Repository".
8+
from .repository import Repository as Repository # isort: skip
9+
410
from . import enums
511
from ._build import __version__ as __version__
6-
from ._pygit2 import *
12+
from ._pygit2 import * # type: ignore[assignment]
713
from .blame import Blame as Blame, BlameHunk as BlameHunk
814
from .blob import BlobIO as BlobIO
915
from .callbacks import (
@@ -21,7 +27,7 @@ from .index import Index as Index, IndexEntry as IndexEntry
2127
from .legacyenums import *
2228
from .packbuilder import PackBuilder as PackBuilder
2329
from .remotes import Remote as Remote
24-
from .repository import Repository # type: ignore[assignment]
30+
from .repository import Repository as Repository # noqa: F811 # intentional workaround
2531
from .settings import Settings
2632
from .submodules import Submodule as Submodule
2733

0 commit comments

Comments
 (0)