Skip to content

Commit 6569d66

Browse files
committed
fix typing in test folder
also include test folder in mypy check in ci
1 parent ffe28ac commit 6569d66

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ if [ "$1" = "mypy" ]; then
269269
$PREFIX/bin/pip install $WHEELDIR/pygit2*-$PYTHON_TAG-*.whl
270270
fi
271271
$PREFIX/bin/pip install -r requirements-test.txt
272-
$PREFIX/bin/mypy pygit2
272+
$PREFIX/bin/mypy pygit2 test
273273
fi
274274

275275
# Test .pyi stub file

pygit2/_pygit2.pyi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ class Object:
286286
short_id: str
287287
type: 'Literal[GIT_OBJ_COMMIT] | Literal[GIT_OBJ_TREE] | Literal[GIT_OBJ_TAG] | Literal[GIT_OBJ_BLOB]'
288288
type_str: "Literal['commit'] | Literal['tree'] | Literal['tag'] | Literal['blob']"
289+
author: Signature
290+
tree: Tree
289291
@overload
290292
def peel(
291293
self, target_type: 'Literal[GIT_OBJ_COMMIT] | Type[Commit]'
@@ -675,9 +677,11 @@ class Branches:
675677
def __getitem__(self, name: str) -> Branch: ...
676678
def get(self, key: str) -> Branch: ...
677679
def __iter__(self) -> Iterator[str]: ...
678-
def create(self, name: str, commit: Commit, force: bool = False) -> Branch: ...
680+
def create(
681+
self, name: str, commit: Object | Commit, force: bool = False
682+
) -> Branch: ...
679683
def delete(self, name: str) -> None: ...
680-
def with_commit(self, commit: Commit | _OidArg | None) -> 'Branches': ...
684+
def with_commit(self, commit: Object | Commit | _OidArg | None) -> 'Branches': ...
681685
def __contains__(self, name: _OidArg) -> bool: ...
682686

683687
class Repository:

test/test_refs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def test_refs_list(testrepo: Repository) -> None:
6161
def test_head(testrepo: Repository) -> None:
6262
head = testrepo.head
6363
assert LAST_COMMIT == testrepo[head.target].id
64+
assert not isinstance(head.raw_target, bytes)
6465
assert LAST_COMMIT == testrepo[head.raw_target].id
6566

6667

@@ -248,6 +249,7 @@ def test_refs_create_symbolic(testrepo: Repository) -> None:
248249
def test_refs_peel(testrepo: Repository) -> None:
249250
ref = testrepo.references.get('refs/heads/master')
250251
assert testrepo[ref.target].id == ref.peel().id
252+
assert not isinstance(ref.raw_target, bytes)
251253
assert testrepo[ref.raw_target].id == ref.peel().id
252254

253255
commit = ref.peel(Commit)

0 commit comments

Comments
 (0)