mirror of https://github.com/zulip/zulip.git
Add PEP-484 type annotations to global dictionaties.
This commit is contained in:
parent
77be524dc4
commit
b99313545e
|
@ -9,7 +9,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
||||||
|
|
||||||
from zerver.lib.user_agent import parse_user_agent
|
from zerver.lib.user_agent import parse_user_agent
|
||||||
|
|
||||||
user_agents_parsed = defaultdict(int)
|
user_agents_parsed = defaultdict(int) # type: Dict[str, int]
|
||||||
user_agents_path = os.path.join(os.path.dirname(__file__), "user_agents_unique")
|
user_agents_path = os.path.join(os.path.dirname(__file__), "user_agents_unique")
|
||||||
parse_errors = 0
|
parse_errors = 0
|
||||||
for line in open(user_agents_path).readlines():
|
for line in open(user_agents_path).readlines():
|
||||||
|
|
|
@ -296,11 +296,11 @@ class EventQueue(object):
|
||||||
return contents
|
return contents
|
||||||
|
|
||||||
# maps queue ids to client descriptors
|
# maps queue ids to client descriptors
|
||||||
clients = {}
|
clients = {} # type: Dict[int, ClientDescriptor]
|
||||||
# maps user id to list of client descriptors
|
# maps user id to list of client descriptors
|
||||||
user_clients = {}
|
user_clients = {} # type: Dict[int, List[ClientDescriptor]]
|
||||||
# maps realm id to list of client descriptors with all_public_streams=True
|
# maps realm id to list of client descriptors with all_public_streams=True
|
||||||
realm_clients_all_streams = {}
|
realm_clients_all_streams = {} # type: Dict[int, List[ClientDescriptor]]
|
||||||
|
|
||||||
# list of registered gc hooks.
|
# list of registered gc hooks.
|
||||||
# each one will be called with a user profile id, queue, and bool
|
# each one will be called with a user profile id, queue, and bool
|
||||||
|
|
|
@ -40,7 +40,7 @@ def get_user_profile(session_id):
|
||||||
except (UserProfile.DoesNotExist, KeyError):
|
except (UserProfile.DoesNotExist, KeyError):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
connections = dict()
|
connections = dict() # type: Dict[int, SocketConnection]
|
||||||
|
|
||||||
def get_connection(id):
|
def get_connection(id):
|
||||||
return connections.get(id)
|
return connections.get(id)
|
||||||
|
|
|
@ -36,7 +36,7 @@ MAX_MESSAGE_LENGTH = 10000
|
||||||
|
|
||||||
# Doing 1000 remote cache requests to get_display_recipient is quite slow,
|
# Doing 1000 remote cache requests to get_display_recipient is quite slow,
|
||||||
# so add a local cache as well as the remote cache cache.
|
# so add a local cache as well as the remote cache cache.
|
||||||
per_request_display_recipient_cache = {}
|
per_request_display_recipient_cache = {} # type: Dict[int, List[Dict[str, Any]]]
|
||||||
def get_display_recipient_by_id(recipient_id, recipient_type, recipient_type_id):
|
def get_display_recipient_by_id(recipient_id, recipient_type, recipient_type_id):
|
||||||
if recipient_id not in per_request_display_recipient_cache:
|
if recipient_id not in per_request_display_recipient_cache:
|
||||||
result = get_display_recipient_remote_cache(recipient_id, recipient_type, recipient_type_id)
|
result = get_display_recipient_remote_cache(recipient_id, recipient_type, recipient_type_id)
|
||||||
|
@ -253,7 +253,7 @@ def get_realm_filters_cache_key(domain):
|
||||||
return 'all_realm_filters:%s' % (domain,)
|
return 'all_realm_filters:%s' % (domain,)
|
||||||
|
|
||||||
# We have a per-process cache to avoid doing 1000 remote cache queries during page load
|
# We have a per-process cache to avoid doing 1000 remote cache queries during page load
|
||||||
per_request_realm_filters_cache = {}
|
per_request_realm_filters_cache = {} # type: Dict[str, List[RealmFilter]]
|
||||||
def realm_filters_for_domain(domain):
|
def realm_filters_for_domain(domain):
|
||||||
domain = domain.lower()
|
domain = domain.lower()
|
||||||
if domain not in per_request_realm_filters_cache:
|
if domain not in per_request_realm_filters_cache:
|
||||||
|
@ -585,7 +585,7 @@ class Recipient(models.Model):
|
||||||
class Client(models.Model):
|
class Client(models.Model):
|
||||||
name = models.CharField(max_length=30, db_index=True, unique=True)
|
name = models.CharField(max_length=30, db_index=True, unique=True)
|
||||||
|
|
||||||
get_client_cache = {}
|
get_client_cache = {} # type: Dict[str, Client]
|
||||||
def get_client(name):
|
def get_client(name):
|
||||||
if name not in get_client_cache:
|
if name not in get_client_cache:
|
||||||
result = get_client_remote_cache(name)
|
result = get_client_remote_cache(name)
|
||||||
|
|
|
@ -42,8 +42,10 @@ class MITNameTest(TestCase):
|
||||||
self.assertTrue(not_mit_mailing_list("sipbexch@mit.edu"))
|
self.assertTrue(not_mit_mailing_list("sipbexch@mit.edu"))
|
||||||
|
|
||||||
class S3Test(AuthedTestCase):
|
class S3Test(AuthedTestCase):
|
||||||
test_uris = [] # full URIs in public bucket
|
# full URIs in public bucket
|
||||||
test_keys = [] # keys in authed bucket
|
test_uris = [] # type: List[str]
|
||||||
|
# keys in authed bucket
|
||||||
|
test_keys = [] # type: List[str]
|
||||||
|
|
||||||
@slow(2.6, "has to contact external S3 service")
|
@slow(2.6, "has to contact external S3 service")
|
||||||
@skip("Need S3 mock")
|
@skip("Need S3 mock")
|
||||||
|
|
|
@ -245,7 +245,7 @@ class Command(BaseCommand):
|
||||||
if options["replay_old_messages"]:
|
if options["replay_old_messages"]:
|
||||||
restore_saved_messages()
|
restore_saved_messages()
|
||||||
|
|
||||||
recipient_hash = {}
|
recipient_hash = {} # type: Dict[int, Recipient]
|
||||||
def get_recipient_by_id(rid):
|
def get_recipient_by_id(rid):
|
||||||
if rid in recipient_hash:
|
if rid in recipient_hash:
|
||||||
return recipient_hash[rid]
|
return recipient_hash[rid]
|
||||||
|
|
Loading…
Reference in New Issue