some type annotations

This commit is contained in:
Jean-Paul Calderone 2021-11-05 14:10:27 -04:00
parent 0cd96ed713
commit 5d703d9893

View File

@ -187,7 +187,7 @@ class LeaseInfo(object):
return timing_safe_compare(self.renew_secret, candidate_secret) return timing_safe_compare(self.renew_secret, candidate_secret)
def present_renew_secret(self): def present_renew_secret(self):
# type: () -> bytes # type: () -> str
""" """
Return the renew secret, base32-encoded. Return the renew secret, base32-encoded.
""" """
@ -204,7 +204,7 @@ class LeaseInfo(object):
return timing_safe_compare(self.cancel_secret, candidate_secret) return timing_safe_compare(self.cancel_secret, candidate_secret)
def present_cancel_secret(self): def present_cancel_secret(self):
# type: () -> bytes # type: () -> str
""" """
Return the cancel secret, base32-encoded. Return the cancel secret, base32-encoded.
""" """
@ -288,6 +288,7 @@ class HashedLeaseInfo(proxyForInterface(ILeaseInfo, "_lease_info")): # type: ign
_hash = attr.ib() _hash = attr.ib()
def is_renew_secret(self, candidate_secret): def is_renew_secret(self, candidate_secret):
# type: (bytes) -> bool
""" """
Hash the candidate secret and compare the result to the stored hashed Hash the candidate secret and compare the result to the stored hashed
secret. secret.
@ -295,12 +296,14 @@ class HashedLeaseInfo(proxyForInterface(ILeaseInfo, "_lease_info")): # type: ign
return super(HashedLeaseInfo, self).is_renew_secret(self._hash(candidate_secret)) return super(HashedLeaseInfo, self).is_renew_secret(self._hash(candidate_secret))
def present_renew_secret(self): def present_renew_secret(self):
# type: () -> str
""" """
Present the hash of the secret with a marker indicating it is a hash. Present the hash of the secret with a marker indicating it is a hash.
""" """
return u"hash:" + super(HashedLeaseInfo, self).present_renew_secret() return u"hash:" + super(HashedLeaseInfo, self).present_renew_secret()
def is_cancel_secret(self, candidate_secret): def is_cancel_secret(self, candidate_secret):
# type: (bytes) -> bool
""" """
Hash the candidate secret and compare the result to the stored hashed Hash the candidate secret and compare the result to the stored hashed
secret. secret.
@ -322,6 +325,7 @@ class HashedLeaseInfo(proxyForInterface(ILeaseInfo, "_lease_info")): # type: ign
return super(HashedLeaseInfo, self).is_cancel_secret(hashed_candidate) return super(HashedLeaseInfo, self).is_cancel_secret(hashed_candidate)
def present_cancel_secret(self): def present_cancel_secret(self):
# type: () -> str
""" """
Present the hash of the secret with a marker indicating it is a hash. Present the hash of the secret with a marker indicating it is a hash.
""" """