Skip to content

Commit 11f9a67

Browse files
committed
imporve types accoding to test/test_attributes.py
1 parent f40d129 commit 11f9a67

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

pygit2/_pygit2.pyi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
from typing import Iterator, Literal, Optional, overload, Type, TypedDict
22
from io import IOBase, DEFAULT_BUFFER_SIZE
3+
from pathlib import Path
34
from queue import Queue
45
import tarfile
56
from threading import Event
67
from . import Index
78
from .enums import (
9+
AttrCheck,
810
ApplyLocation,
911
BranchType,
1012
BlobFilter,
@@ -793,6 +795,13 @@ class Repository:
793795
def descendant_of(self, oid1: _OidArg, oid2: _OidArg) -> bool: ...
794796
def expand_id(self, hex: str) -> Oid: ...
795797
def free(self) -> None: ...
798+
def get_attr(
799+
self,
800+
path: str | bytes | Path,
801+
name: str | bytes,
802+
flags: AttrCheck = AttrCheck.FILE_THEN_INDEX,
803+
commit: _OidArg | None = None,
804+
) -> bool | None | str: ...
796805
def git_object_lookup_prefix(self, oid: _OidArg) -> Object: ...
797806
def list_worktrees(self) -> list[str]: ...
798807
def listall_branches(self, flag: BranchType = BranchType.LOCAL) -> list[str]: ...

test/test_attributes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
# Standard Library
2727
from pathlib import Path
2828

29+
from pygit2 import Repository
2930

30-
def test_no_attr(testrepo):
31+
32+
def test_no_attr(testrepo: Repository) -> None:
3133
assert testrepo.get_attr('file', 'foo') is None
3234

3335
with (Path(testrepo.workdir) / '.gitattributes').open('w+') as f:
@@ -41,7 +43,7 @@ def test_no_attr(testrepo):
4143
assert 'lf' == testrepo.get_attr('file.sh', 'eol')
4244

4345

44-
def test_no_attr_aspath(testrepo):
46+
def test_no_attr_aspath(testrepo: Repository) -> None:
4547
with (Path(testrepo.workdir) / '.gitattributes').open('w+') as f:
4648
print('*.py text\n', file=f)
4749

0 commit comments

Comments
 (0)