Skip to content

Commit efbfb81

Browse files
committed
Fix some disallow_untyped_defs
1 parent ff66108 commit efbfb81

File tree

6 files changed

+15
-14
lines changed

6 files changed

+15
-14
lines changed

pygit2/_build.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#
4141
# Utility functions to get the paths required for building extensions
4242
#
43-
def _get_libgit2_path():
43+
def _get_libgit2_path() -> Path:
4444
# LIBGIT2 environment variable takes precedence
4545
libgit2_path = os.getenv('LIBGIT2')
4646
if libgit2_path is not None:
@@ -52,7 +52,7 @@ def _get_libgit2_path():
5252
return Path('/usr/local')
5353

5454

55-
def get_libgit2_paths():
55+
def get_libgit2_paths() -> tuple[Path, dict[str, list[str]]]:
5656
# Base path
5757
path = _get_libgit2_path()
5858

@@ -61,7 +61,7 @@ def get_libgit2_paths():
6161
if libgit2_lib is None:
6262
library_dirs = [path / 'lib', path / 'lib64']
6363
else:
64-
library_dirs = [libgit2_lib]
64+
library_dirs = [Path(libgit2_lib)]
6565

6666
include_dirs = [path / 'include']
6767
return (

pygit2/blob.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def readinto(self, b, /):
8484
except KeyboardInterrupt:
8585
return 0
8686

87-
def close(self):
87+
def close(self) -> None:
8888
try:
8989
self._ready.wait()
9090
self._writer_closed.wait()

pygit2/errors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
value_errors = set([C.GIT_EEXISTS, C.GIT_EINVALIDSPEC, C.GIT_EAMBIGUOUS])
3333

3434

35-
def check_error(err, io=False):
35+
def check_error(err: int, io: bool = False) -> None:
3636
if err >= 0:
3737
return
3838

@@ -69,5 +69,5 @@ def check_error(err, io=False):
6969

7070
# Indicate that we want libgit2 to pretend a function was not set
7171
class Passthrough(Exception):
72-
def __init__(self):
72+
def __init__(self) -> None:
7373
super().__init__('The function asked for pass-through')

pygit2/refspec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
class Refspec:
3535
"""The constructor is for internal use only."""
3636

37-
def __init__(self, owner, ptr):
37+
def __init__(self, owner, ptr) -> None:
3838
self._owner = owner
3939
self._refspec = ptr
4040

pygit2/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from types import TracebackType
3030
from typing import (
3131
TYPE_CHECKING,
32+
Any,
3233
Generic,
3334
Optional,
3435
Protocol,
@@ -80,7 +81,7 @@ def to_bytes(
8081
return s.encode(encoding, errors) # type: ignore[union-attr]
8182

8283

83-
def to_str(s):
84+
def to_str(s: str | bytes | os.PathLike[Any]) -> str:
8485
if hasattr(s, '__fspath__'):
8586
s = os.fspath(s)
8687

@@ -93,7 +94,7 @@ def to_str(s):
9394
raise TypeError(f'unexpected type "{repr(s)}"')
9495

9596

96-
def ptr_to_bytes(ptr_cdata):
97+
def ptr_to_bytes(ptr_cdata) -> bytes:
9798
"""
9899
Convert a pointer coming from C code (<cdata 'some_type *'>)
99100
to a byte buffer containing the address that the pointer refers to.
@@ -110,7 +111,7 @@ def new_git_strarray() -> Generator['GitStrrayC', None, None]:
110111
C.git_strarray_dispose(strarray)
111112

112113

113-
def strarray_to_strings(arr):
114+
def strarray_to_strings(arr) -> list[str]:
114115
"""
115116
Return a list of strings from a git_strarray pointer.
116117

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848

4949
class sdist_files_from_git(sdist):
50-
def get_file_list(self):
50+
def get_file_list(self) -> None:
5151
popen = Popen(
5252
['git', 'ls-files'], stdout=PIPE, stderr=PIPE, universal_newlines=True
5353
)
@@ -56,7 +56,7 @@ def get_file_list(self):
5656
print(stderrdata)
5757
sys.exit()
5858

59-
def exclude(line):
59+
def exclude(line: str) -> bool:
6060
for prefix in ['.', 'appveyor.yml', 'docs/', 'misc/']:
6161
if line.startswith(prefix):
6262
return True
@@ -97,7 +97,7 @@ def exclude(line):
9797

9898
# On Windows, we install the git2.dll too.
9999
class BuildWithDLLs(build):
100-
def _get_dlls(self):
100+
def _get_dlls(self) -> list[tuple[Path, Path]]:
101101
# return a list of (FQ-in-name, relative-out-name) tuples.
102102
ret = []
103103
bld_ext = self.distribution.get_command_obj('build_ext')
@@ -121,7 +121,7 @@ def _get_dlls(self):
121121
log.debug(f'(looked in {look_dirs})')
122122
return ret
123123

124-
def run(self):
124+
def run(self) -> None:
125125
build.run(self)
126126
for s, d in self._get_dlls():
127127
self.copy_file(s, d)

0 commit comments

Comments
 (0)