diff --git a/knox/auth.py b/knox/auth.py index bf3749e2..ffb0880b 100644 --- a/knox/auth.py +++ b/knox/auth.py @@ -71,7 +71,7 @@ def authenticate_credentials(self, token): return self.validate_user(auth_token) raise exceptions.AuthenticationFailed(msg) - def renew_token(self, auth_token): + def renew_token(self, auth_token) -> None: current_expiry = auth_token.expiry new_expiry = timezone.now() + knox_settings.TOKEN_TTL auth_token.expiry = new_expiry @@ -89,7 +89,7 @@ def validate_user(self, auth_token): def authenticate_header(self, request): return knox_settings.AUTH_HEADER_PREFIX - def _cleanup_token(self, auth_token): + def _cleanup_token(self, auth_token) -> bool: for other_token in auth_token.user.auth_token_set.all(): if other_token.digest != auth_token.digest and other_token.expiry: if other_token.expiry < timezone.now(): diff --git a/knox/crypto.py b/knox/crypto.py index 1ee36146..02e70ffe 100644 --- a/knox/crypto.py +++ b/knox/crypto.py @@ -6,13 +6,13 @@ hash_func = knox_settings.SECURE_HASH_ALGORITHM -def create_token_string(): +def create_token_string() -> str: return binascii.hexlify( generate_bytes(int(knox_settings.AUTH_TOKEN_CHARACTER_LENGTH / 2)) ).decode() -def make_hex_compatible(token: str) -> str: +def make_hex_compatible(token: str) -> bytes: """ We need to make sure that the token, that is send is hex-compatible. When a token prefix is used, we cannot guarantee that. diff --git a/knox/models.py b/knox/models.py index b054f289..80929bcf 100644 --- a/knox/models.py +++ b/knox/models.py @@ -48,7 +48,7 @@ class AbstractAuthToken(models.Model): class Meta: abstract = True - def __str__(self): + def __str__(self) -> str: return '%s : %s' % (self.digest, self.user) diff --git a/knox/settings.py b/knox/settings.py index a5def499..d1b09347 100644 --- a/knox/settings.py +++ b/knox/settings.py @@ -55,4 +55,4 @@ def __setattr__(self, *args, **kwargs): ''') -CONSTANTS = CONSTANTS() +CONSTANTS = CONSTANTS() # type: ignore