Skip to content

Commit 9a1affc

Browse files
committed
add typing to errors.py
1 parent 3aabbc7 commit 9a1affc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pygit2/errors.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
value_errors = {C.GIT_EEXISTS, C.GIT_EINVALIDSPEC, C.GIT_EAMBIGUOUS}
3131

3232

33-
def check_error(err, io=False):
33+
def check_error(err: int, io: bool = False) -> None:
3434
if err >= 0:
3535
return
3636

@@ -41,7 +41,9 @@ def check_error(err, io=False):
4141
# Error message
4242
giterr = C.git_error_last()
4343
if giterr != ffi.NULL:
44-
message = ffi.string(giterr.message).decode('utf8')
44+
message = ffi.string(giterr.message)
45+
if isinstance(message, bytes):
46+
message = message.decode('utf8')
4547
else:
4648
message = f'err {err} (no message provided)'
4749

@@ -66,6 +68,6 @@ def check_error(err, io=False):
6668

6769

6870
# Indicate that we want libgit2 to pretend a function was not set
69-
class Passthrough(Exception):
71+
class Passthrough(NotImplementedError):
7072
def __init__(self):
7173
super().__init__('The function asked for pass-through')

0 commit comments

Comments
 (0)