Fix zerver.lib.utils.generate_random_token.

generate_random_token used to return a value of type six.binary_type
and its return type was annotated as `str`.  This commit fixes that
by making it return a value of type `six.text_type` and updating
the annotation accordingly.
Also fix clashing annnotations.
This commit is contained in:
Eklavya Sharma
2016-06-12 15:54:27 +05:30
committed by Tim Abbott
parent 56d5785c2e
commit 10f2ec043d
3 changed files with 4 additions and 4 deletions

View File

@@ -110,5 +110,5 @@ def log_statsd_event(name):
statsd.incr(event_name)
def generate_random_token(length):
# type: (int) -> str
return base64.b16encode(os.urandom(length // 2)).lower()
# type: (int) -> text_type
return base64.b16encode(os.urandom(length // 2)).decode('utf-8').lower()

View File

@@ -541,7 +541,7 @@ class MitUser(models.Model):
status = models.IntegerField(default=0)
def generate_email_token_for_stream():
# type: () -> str
# type: () -> text_type
return generate_random_token(32)
class Stream(models.Model):

View File

@@ -961,7 +961,7 @@ def update_pointer_backend(request, user_profile,
return json_success()
def generate_client_id():
# type: () -> str
# type: () -> text_type
return generate_random_token(32)
# The order of creation of the various dictionaries are important.