mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 05:53:43 +00:00
mypy: Convert several directories to use typing.Text.
Specifically, these directories are converted: [analytics/, scripts/, tools/, zerver/management/, zilencer/, zproject/]
This commit is contained in:
committed by
Tim Abbott
parent
2288120155
commit
beaa62cafa
@@ -5,7 +5,7 @@ from __future__ import print_function
|
||||
import sys, os, os.path
|
||||
from os.path import dirname, abspath
|
||||
if False:
|
||||
from typing import Dict, Optional
|
||||
from typing import Dict, Optional, Text
|
||||
|
||||
BASE_DIR = dirname(dirname(dirname(abspath(__file__))))
|
||||
sys.path.append(BASE_DIR)
|
||||
@@ -14,7 +14,6 @@ import scripts.lib.setup_path_on_import
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.settings'
|
||||
|
||||
from django.utils.crypto import get_random_string
|
||||
from six import text_type
|
||||
import six
|
||||
import argparse
|
||||
from zerver.lib.str_utils import force_str
|
||||
@@ -30,7 +29,7 @@ AUTOGENERATED_SETTINGS = ['shared_secret', 'avatar_salt', 'rabbitmq_password', '
|
||||
# TODO: We can eliminate this function if we refactor the install
|
||||
# script to run generate_secrets before zulip-puppet-apply.
|
||||
def generate_camo_config_file(camo_key):
|
||||
# type: (text_type) -> None
|
||||
# type: (Text) -> None
|
||||
camo_config = """ENABLED=yes
|
||||
PORT=9292
|
||||
CAMO_KEY=%s
|
||||
@@ -40,13 +39,13 @@ CAMO_KEY=%s
|
||||
print("Generated Camo config file %s" % (CAMO_CONFIG_FILENAME,))
|
||||
|
||||
def generate_django_secretkey():
|
||||
# type: () -> text_type
|
||||
# type: () -> Text
|
||||
"""Secret key generation taken from Django's startproject.py"""
|
||||
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
|
||||
return get_random_string(50, chars)
|
||||
|
||||
def get_old_conf(output_filename):
|
||||
# type: (text_type) -> Dict[str, text_type]
|
||||
# type: (Text) -> Dict[str, Text]
|
||||
if not os.path.exists(output_filename):
|
||||
return {}
|
||||
|
||||
@@ -54,7 +53,7 @@ def get_old_conf(output_filename):
|
||||
secrets_file.read(output_filename)
|
||||
|
||||
def get_secret(key):
|
||||
# type: (text_type) -> Optional[text_type]
|
||||
# type: (Text) -> Optional[Text]
|
||||
if secrets_file.has_option('secrets', key):
|
||||
return secrets_file.get('secrets', key)
|
||||
return None
|
||||
@@ -72,7 +71,7 @@ def generate_secrets(development=False):
|
||||
lines = [u'[secrets]\n']
|
||||
|
||||
def config_line(var, value):
|
||||
# type: (text_type, text_type) -> text_type
|
||||
# type: (Text, Text) -> Text
|
||||
return "%s = %s\n" % (var, value)
|
||||
|
||||
old_conf = get_old_conf(OUTPUT_SETTINGS_FILENAME)
|
||||
|
||||
Reference in New Issue
Block a user