typing: Apply trivial none-checks with assertions as necessary.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li
2022-06-14 23:17:23 -04:00
committed by Tim Abbott
parent 58e95cbfae
commit fd9a0f4274
7 changed files with 10 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ from django.conf import settings
def generate_camo_url(url: str) -> str:
encoded_url = url.encode()
assert settings.CAMO_KEY is not None
encoded_camo_key = settings.CAMO_KEY.encode()
digest = hmac.new(encoded_camo_key, encoded_url, hashlib.sha1).hexdigest()
return f"{digest}/{encoded_url.hex()}"