mypy: Rewrite sign_is_valid in zthumbor helpers.py for None secret_key.

This commit is contained in:
neiljp (Neil Pilgrim) 2018-03-24 22:33:02 +00:00 committed by Tim Abbott
parent 8b697b4093
commit 3b28d6ab8b
2 changed files with 4 additions and 6 deletions

View File

@ -89,9 +89,6 @@ strict_optional = False
[mypy-zilencer.management.commands.add_new_realm] #22: error: List item 0 has incompatible type "Optional[Stream]"; expected "Stream"
strict_optional = False
[mypy-zthumbor.loaders.helpers] #83: error: Argument 2 to "get_sign_hash" has incompatible type "Optional[str]"; expected "str"
strict_optional = False
# Re-architecting required?
[mypy-zerver.lib.queue] # Delayed setup of SimpleQueueClient.channel (Optional)

View File

@ -80,6 +80,7 @@ def sign_is_valid(url, context):
force_text(size),
force_text(source_type),
])
if sign == get_sign_hash(raw, get_secret('thumbor_key')):
return True
return False
secret_key = get_secret('thumbor_key')
if secret_key is None or sign != get_sign_hash(raw, secret_key):
return False
return True