Skip to content

Commit 43e851f

Browse files
committed
More typing
1 parent ff414d5 commit 43e851f

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

pygit2/callbacks.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@
8282

8383

8484
class Payload:
85-
def __init__(self, **kw):
85+
def __init__(self, **kw: object):
8686
for key, value in kw.items():
8787
setattr(self, key, value)
8888
self._stored_exception = None
8989

90-
def check_error(self, error_code):
90+
def check_error(self, error_code: int) -> None:
9191
if error_code == C.GIT_EUSER:
9292
assert self._stored_exception is not None
9393
raise self._stored_exception
@@ -120,7 +120,7 @@ def __init__(self, credentials=None, certificate_check=None):
120120
if certificate_check is not None:
121121
self.certificate_check = certificate_check
122122

123-
def sideband_progress(self, string):
123+
def sideband_progress(self, string: str):
124124
"""
125125
Progress output callback. Override this function with your own
126126
progress reporting function
@@ -159,7 +159,7 @@ def credentials(
159159
"""
160160
raise Passthrough
161161

162-
def certificate_check(self, certificate, valid, host):
162+
def certificate_check(self, certificate: None, valid: bool, host: str) -> bool:
163163
"""
164164
Certificate callback. Override with your own function to determine
165165
whether to accept the server's certificate.

pygit2/credentials.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
2424
# Boston, MA 02110-1301, USA.
2525

26+
from __future__ import annotations
27+
2628
from .ffi import C
2729

2830
from .enums import CredentialType
@@ -35,7 +37,7 @@ class Username:
3537
callback and for returning from said callback.
3638
"""
3739

38-
def __init__(self, username):
40+
def __init__(self, username: str):
3941
self._username = username
4042

4143
@property
@@ -46,7 +48,7 @@ def credential_type(self) -> CredentialType:
4648
def credential_tuple(self):
4749
return (self._username,)
4850

49-
def __call__(self, _url, _username, _allowed):
51+
def __call__(self, _url: str, _username: str | None, _allowed: CredentialType) -> Username:
5052
return self
5153

5254

@@ -57,7 +59,7 @@ class UserPass:
5759
callback and for returning from said callback.
5860
"""
5961

60-
def __init__(self, username, password):
62+
def __init__(self, username: str, password: str):
6163
self._username = username
6264
self._password = password
6365

@@ -69,7 +71,7 @@ def credential_type(self) -> CredentialType:
6971
def credential_tuple(self):
7072
return (self._username, self._password)
7173

72-
def __call__(self, _url, _username, _allowed):
74+
def __call__(self, _url: str, _username: str | None, _allowed: CredentialType) -> UserPass:
7375
return self
7476

7577

@@ -96,7 +98,7 @@ class Keypair:
9698
no passphrase is required.
9799
"""
98100

99-
def __init__(self, username, pubkey, privkey, passphrase):
101+
def __init__(self, username: str, pubkey: str, privkey: str, passphrase: str):
100102
self._username = username
101103
self._pubkey = pubkey
102104
self._privkey = privkey
@@ -110,12 +112,12 @@ def credential_type(self) -> CredentialType:
110112
def credential_tuple(self):
111113
return (self._username, self._pubkey, self._privkey, self._passphrase)
112114

113-
def __call__(self, _url, _username, _allowed):
115+
def __call__(self, _url: str, _username: str | None, _allowed: CredentialType) -> Keypair:
114116
return self
115117

116118

117119
class KeypairFromAgent(Keypair):
118-
def __init__(self, username):
120+
def __init__(self, username: str):
119121
super().__init__(username, None, None, None)
120122

121123

pygit2/remotes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def names(self):
335335
for name in self._ffi_names():
336336
yield maybe_string(name)
337337

338-
def create(self, name, url, fetch=None):
338+
def create(self, name, url, fetch=None) -> Remote:
339339
"""Create a new remote with the given name and url. Returns a <Remote>
340340
object.
341341

0 commit comments

Comments
 (0)