mirror of https://github.com/zulip/zulip.git
python: Rewrite dict() as {}.
Suggested by the flake8-comprehensions plugin. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
a610bd19a1
commit
a276eefcfe
|
@ -155,7 +155,7 @@ def check_rabbitmq_queues() -> None:
|
||||||
list_consumers_output = subprocess.check_output(['/usr/sbin/rabbitmqctl', 'list_consumers'],
|
list_consumers_output = subprocess.check_output(['/usr/sbin/rabbitmqctl', 'list_consumers'],
|
||||||
universal_newlines=True)
|
universal_newlines=True)
|
||||||
|
|
||||||
queue_counts_rabbitmqctl = dict()
|
queue_counts_rabbitmqctl = {}
|
||||||
for line in list_queues_output.split("\n"):
|
for line in list_queues_output.split("\n"):
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
m = pattern.match(line)
|
m = pattern.match(line)
|
||||||
|
@ -176,7 +176,7 @@ def check_rabbitmq_queues() -> None:
|
||||||
queue_stats_dir = subprocess.check_output([os.path.join(ZULIP_PATH, 'scripts/get-django-setting'),
|
queue_stats_dir = subprocess.check_output([os.path.join(ZULIP_PATH, 'scripts/get-django-setting'),
|
||||||
'QUEUE_STATS_DIR'],
|
'QUEUE_STATS_DIR'],
|
||||||
universal_newlines=True).strip()
|
universal_newlines=True).strip()
|
||||||
queue_stats: Dict[str, Dict[str, Any]] = dict()
|
queue_stats: Dict[str, Dict[str, Any]] = {}
|
||||||
queues_to_check = set(normal_queues).intersection(set(queues_with_consumers))
|
queues_to_check = set(normal_queues).intersection(set(queues_with_consumers))
|
||||||
for queue in queues_to_check:
|
for queue in queues_to_check:
|
||||||
fn = queue + ".stats"
|
fn = queue + ".stats"
|
||||||
|
|
|
@ -124,7 +124,7 @@ def create_user_docs() -> None:
|
||||||
('json', 'legacy'),
|
('json', 'legacy'),
|
||||||
]
|
]
|
||||||
|
|
||||||
groups: Dict[str, Set[str]] = dict()
|
groups: Dict[str, Set[str]] = {}
|
||||||
for prefix, name in tups:
|
for prefix, name in tups:
|
||||||
groups[name] = {p for p in patterns if p.startswith(prefix)}
|
groups[name] = {p for p in patterns if p.startswith(prefix)}
|
||||||
patterns -= groups[name]
|
patterns -= groups[name]
|
||||||
|
|
|
@ -661,7 +661,7 @@ def process_raw_message_batch(realm_id: int,
|
||||||
content = content.replace('@here', '@**all**')
|
content = content.replace('@here', '@**all**')
|
||||||
return content
|
return content
|
||||||
|
|
||||||
mention_map: Dict[int, Set[int]] = dict()
|
mention_map: Dict[int, Set[int]] = {}
|
||||||
|
|
||||||
zerver_message = []
|
zerver_message = []
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ from zerver.data_import.import_util import build_attachment, create_converted_da
|
||||||
|
|
||||||
class AttachmentHandler:
|
class AttachmentHandler:
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.info_dict: Dict[str, Dict[str, Any]] = dict()
|
self.info_dict: Dict[str, Dict[str, Any]] = {}
|
||||||
|
|
||||||
def handle_message_data(self,
|
def handle_message_data(self,
|
||||||
realm_id: int,
|
realm_id: int,
|
||||||
|
|
|
@ -20,8 +20,8 @@ class UserHandler:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.id_to_user_map: Dict[int, Dict[str, Any]] = dict()
|
self.id_to_user_map: Dict[int, Dict[str, Any]] = {}
|
||||||
self.name_to_mirror_user_map: Dict[str, Dict[str, Any]] = dict()
|
self.name_to_mirror_user_map: Dict[str, Dict[str, Any]] = {}
|
||||||
self.mirror_user_id = 1
|
self.mirror_user_id = 1
|
||||||
|
|
||||||
def add_user(self, user: Dict[str, Any]) -> None:
|
def add_user(self, user: Dict[str, Any]) -> None:
|
||||||
|
|
|
@ -41,8 +41,8 @@ ZerverFieldsT = Dict[str, Any]
|
||||||
|
|
||||||
class SubscriberHandler:
|
class SubscriberHandler:
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.stream_info: Dict[int, Set[int]] = dict()
|
self.stream_info: Dict[int, Set[int]] = {}
|
||||||
self.huddle_info: Dict[int, Set[int]] = dict()
|
self.huddle_info: Dict[int, Set[int]] = {}
|
||||||
|
|
||||||
def set_info(self,
|
def set_info(self,
|
||||||
users: Set[int],
|
users: Set[int],
|
||||||
|
@ -129,7 +129,7 @@ def make_subscriber_map(zerver_subscription: List[ZerverFieldsT]) -> Dict[int, S
|
||||||
This can be convenient for building up UserMessage
|
This can be convenient for building up UserMessage
|
||||||
rows.
|
rows.
|
||||||
'''
|
'''
|
||||||
subscriber_map: Dict[int, Set[int]] = dict()
|
subscriber_map: Dict[int, Set[int]] = {}
|
||||||
for sub in zerver_subscription:
|
for sub in zerver_subscription:
|
||||||
user_id = sub['user_profile']
|
user_id = sub['user_profile']
|
||||||
recipient_id = sub['recipient']
|
recipient_id = sub['recipient']
|
||||||
|
|
|
@ -319,7 +319,7 @@ def process_raw_message_batch(realm_id: int,
|
||||||
content = content.replace('@here', '@**all**')
|
content = content.replace('@here', '@**all**')
|
||||||
return content
|
return content
|
||||||
|
|
||||||
mention_map: Dict[int, Set[int]] = dict()
|
mention_map: Dict[int, Set[int]] = {}
|
||||||
zerver_message = []
|
zerver_message = []
|
||||||
|
|
||||||
import html2text
|
import html2text
|
||||||
|
|
|
@ -12,7 +12,7 @@ class UserHandler:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.id_to_user_map: Dict[int, Dict[str, Any]] = dict()
|
self.id_to_user_map: Dict[int, Dict[str, Any]] = {}
|
||||||
|
|
||||||
def add_user(self, user: Dict[str, Any]) -> None:
|
def add_user(self, user: Dict[str, Any]) -> None:
|
||||||
user_id = user['id']
|
user_id = user['id']
|
||||||
|
|
|
@ -28,7 +28,7 @@ def sequencer() -> Callable[[str], int]:
|
||||||
NEXT_ID = sequencer()
|
NEXT_ID = sequencer()
|
||||||
message_id = NEXT_ID('message')
|
message_id = NEXT_ID('message')
|
||||||
'''
|
'''
|
||||||
seq_dict: Dict[str, Callable[[], int]] = dict()
|
seq_dict: Dict[str, Callable[[], int]] = {}
|
||||||
|
|
||||||
def next_one(name: str) -> int:
|
def next_one(name: str) -> int:
|
||||||
if name not in seq_dict:
|
if name not in seq_dict:
|
||||||
|
@ -59,7 +59,7 @@ def is_int(key: Any) -> bool:
|
||||||
|
|
||||||
class IdMapper:
|
class IdMapper:
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.map: Dict[Any, int] = dict()
|
self.map: Dict[Any, int] = {}
|
||||||
self.cnt = 0
|
self.cnt = 0
|
||||||
|
|
||||||
def has(self, their_id: Any) -> bool:
|
def has(self, their_id: Any) -> bool:
|
||||||
|
|
|
@ -15,7 +15,7 @@ from zerver.models import AlertWord, Realm, UserProfile, flush_realm_alert_words
|
||||||
def alert_words_in_realm(realm: Realm) -> Dict[int, List[str]]:
|
def alert_words_in_realm(realm: Realm) -> Dict[int, List[str]]:
|
||||||
user_ids_and_words = AlertWord.objects.filter(
|
user_ids_and_words = AlertWord.objects.filter(
|
||||||
realm=realm, user_profile__is_active=True).values("user_profile_id", "word")
|
realm=realm, user_profile__is_active=True).values("user_profile_id", "word")
|
||||||
user_ids_with_words: Dict[int, List[str]] = dict()
|
user_ids_with_words: Dict[int, List[str]] = {}
|
||||||
for id_and_word in user_ids_and_words:
|
for id_and_word in user_ids_and_words:
|
||||||
user_ids_with_words.setdefault(id_and_word["user_profile_id"], [])
|
user_ids_with_words.setdefault(id_and_word["user_profile_id"], [])
|
||||||
user_ids_with_words[id_and_word["user_profile_id"]].append(id_and_word["word"])
|
user_ids_with_words[id_and_word["user_profile_id"]].append(id_and_word["word"])
|
||||||
|
|
|
@ -68,4 +68,4 @@ def load_bot_config_template(bot: str) -> Dict[str, str]:
|
||||||
config.read_file(conf)
|
config.read_file(conf)
|
||||||
return dict(config.items(bot))
|
return dict(config.items(bot))
|
||||||
else:
|
else:
|
||||||
return dict()
|
return {}
|
||||||
|
|
|
@ -125,7 +125,7 @@ class EmbeddedBotHandler:
|
||||||
return get_bot_config(self.user_profile)
|
return get_bot_config(self.user_profile)
|
||||||
except ConfigError:
|
except ConfigError:
|
||||||
if optional:
|
if optional:
|
||||||
return dict()
|
return {}
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def quit(self, message: str= "") -> None:
|
def quit(self, message: str= "") -> None:
|
||||||
|
|
|
@ -810,7 +810,7 @@ def apply_event(state: Dict[str, Any],
|
||||||
status_text = event.get('status_text')
|
status_text = event.get('status_text')
|
||||||
|
|
||||||
if user_id_str not in user_status:
|
if user_id_str not in user_status:
|
||||||
user_status[user_id_str] = dict()
|
user_status[user_id_str] = {}
|
||||||
|
|
||||||
if away is not None:
|
if away is not None:
|
||||||
if away:
|
if away:
|
||||||
|
|
|
@ -754,7 +754,7 @@ class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor):
|
||||||
# and gifs do not work.
|
# and gifs do not work.
|
||||||
# TODO: What if image is huge? Should we get headers first?
|
# TODO: What if image is huge? Should we get headers first?
|
||||||
if image_info is None:
|
if image_info is None:
|
||||||
image_info = dict()
|
image_info = {}
|
||||||
image_info['is_image'] = True
|
image_info['is_image'] = True
|
||||||
parsed_url_list = list(parsed_url)
|
parsed_url_list = list(parsed_url)
|
||||||
parsed_url_list[4] = "dl=1" # Replaces query
|
parsed_url_list[4] = "dl=1" # Replaces query
|
||||||
|
@ -2217,7 +2217,7 @@ class MentionData:
|
||||||
|
|
||||||
def get_user_group_name_info(realm_id: int, user_group_names: Set[str]) -> Dict[str, UserGroup]:
|
def get_user_group_name_info(realm_id: int, user_group_names: Set[str]) -> Dict[str, UserGroup]:
|
||||||
if not user_group_names:
|
if not user_group_names:
|
||||||
return dict()
|
return {}
|
||||||
|
|
||||||
rows = UserGroup.objects.filter(realm_id=realm_id,
|
rows = UserGroup.objects.filter(realm_id=realm_id,
|
||||||
name__in=user_group_names)
|
name__in=user_group_names)
|
||||||
|
@ -2226,7 +2226,7 @@ def get_user_group_name_info(realm_id: int, user_group_names: Set[str]) -> Dict[
|
||||||
|
|
||||||
def get_stream_name_info(realm: Realm, stream_names: Set[str]) -> Dict[str, FullNameInfo]:
|
def get_stream_name_info(realm: Realm, stream_names: Set[str]) -> Dict[str, FullNameInfo]:
|
||||||
if not stream_names:
|
if not stream_names:
|
||||||
return dict()
|
return {}
|
||||||
|
|
||||||
q_list = {
|
q_list = {
|
||||||
Q(name=name)
|
Q(name=name)
|
||||||
|
@ -2323,7 +2323,7 @@ def do_convert(content: str,
|
||||||
if content_has_emoji_syntax(content):
|
if content_has_emoji_syntax(content):
|
||||||
active_realm_emoji = message_realm.get_active_emoji()
|
active_realm_emoji = message_realm.get_active_emoji()
|
||||||
else:
|
else:
|
||||||
active_realm_emoji = dict()
|
active_realm_emoji = {}
|
||||||
|
|
||||||
_md_engine.zulip_db_data = {
|
_md_engine.zulip_db_data = {
|
||||||
'realm_alert_words_automaton': realm_alert_words_automaton,
|
'realm_alert_words_automaton': realm_alert_words_automaton,
|
||||||
|
|
|
@ -730,7 +730,7 @@ def huddle_users(recipient_id: int) -> str:
|
||||||
def aggregate_message_dict(input_dict: Dict[int, Dict[str, Any]],
|
def aggregate_message_dict(input_dict: Dict[int, Dict[str, Any]],
|
||||||
lookup_fields: List[str],
|
lookup_fields: List[str],
|
||||||
collect_senders: bool) -> List[Dict[str, Any]]:
|
collect_senders: bool) -> List[Dict[str, Any]]:
|
||||||
lookup_dict: Dict[Tuple[Any, ...], Dict[str, Any]] = dict()
|
lookup_dict: Dict[Tuple[Any, ...], Dict[str, Any]] = {}
|
||||||
|
|
||||||
'''
|
'''
|
||||||
A concrete example might help explain the inputs here:
|
A concrete example might help explain the inputs here:
|
||||||
|
|
|
@ -33,7 +33,7 @@ def get_status_dicts_for_rows(all_rows: List[Dict[str, Any]],
|
||||||
get_user_key = lambda row: row['user_profile__email']
|
get_user_key = lambda row: row['user_profile__email']
|
||||||
get_user_info = get_legacy_user_info
|
get_user_info = get_legacy_user_info
|
||||||
|
|
||||||
user_statuses: Dict[str, Dict[str, Any]] = dict()
|
user_statuses: Dict[str, Dict[str, Any]] = {}
|
||||||
|
|
||||||
for user_key, presence_rows in itertools.groupby(all_rows, get_user_key):
|
for user_key, presence_rows in itertools.groupby(all_rows, get_user_key):
|
||||||
info = get_user_info(
|
info = get_user_info(
|
||||||
|
@ -64,7 +64,7 @@ def get_modern_user_info(presence_rows: List[Dict[str, Any]],
|
||||||
# Be stingy about bandwidth, and don't even include
|
# Be stingy about bandwidth, and don't even include
|
||||||
# keys for entities that have None values. JS
|
# keys for entities that have None values. JS
|
||||||
# code should just do a falsy check here.
|
# code should just do a falsy check here.
|
||||||
result = dict()
|
result = {}
|
||||||
|
|
||||||
if active_timestamp is not None:
|
if active_timestamp is not None:
|
||||||
result['active_timestamp'] = active_timestamp
|
result['active_timestamp'] = active_timestamp
|
||||||
|
@ -100,7 +100,7 @@ def get_legacy_user_info(presence_rows: List[Dict[str, Any]],
|
||||||
|
|
||||||
most_recent_info = info_rows[-1]
|
most_recent_info = info_rows[-1]
|
||||||
|
|
||||||
result = dict()
|
result = {}
|
||||||
|
|
||||||
# The word "aggegrated" here is possibly misleading.
|
# The word "aggegrated" here is possibly misleading.
|
||||||
# It's really just the most recent client's info.
|
# It's really just the most recent client's info.
|
||||||
|
|
|
@ -21,8 +21,8 @@ class StreamRecipientMap:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.recip_to_stream: Dict[int, int] = dict()
|
self.recip_to_stream: Dict[int, int] = {}
|
||||||
self.stream_to_recip: Dict[int, int] = dict()
|
self.stream_to_recip: Dict[int, int] = {}
|
||||||
|
|
||||||
def populate_with(self, *, stream_id: int, recipient_id: int) -> None:
|
def populate_with(self, *, stream_id: int, recipient_id: int) -> None:
|
||||||
# We use * to enforce using named arguments when calling this function,
|
# We use * to enforce using named arguments when calling this function,
|
||||||
|
|
|
@ -19,13 +19,13 @@ def get_user_info_dict(realm_id: int) -> Dict[str, Dict[str, Any]]:
|
||||||
'status_text',
|
'status_text',
|
||||||
)
|
)
|
||||||
|
|
||||||
user_dict: Dict[str, Dict[str, Any]] = dict()
|
user_dict: Dict[str, Dict[str, Any]] = {}
|
||||||
for row in rows:
|
for row in rows:
|
||||||
away = row['status'] == UserStatus.AWAY
|
away = row['status'] == UserStatus.AWAY
|
||||||
status_text = row['status_text']
|
status_text = row['status_text']
|
||||||
user_id = row['user_profile_id']
|
user_id = row['user_profile_id']
|
||||||
|
|
||||||
dct = dict()
|
dct = {}
|
||||||
if away:
|
if away:
|
||||||
dct['away'] = away
|
dct['away'] = away
|
||||||
if status_text:
|
if status_text:
|
||||||
|
|
|
@ -25,7 +25,7 @@ def process_zcommands(content: str, user_profile: UserProfile) -> Dict[str, Any]
|
||||||
command = content[1:]
|
command = content[1:]
|
||||||
|
|
||||||
if command == 'ping':
|
if command == 'ping':
|
||||||
return dict()
|
return {}
|
||||||
elif command == 'night':
|
elif command == 'night':
|
||||||
if user_profile.color_scheme == UserProfile.COLOR_SCHEME_NIGHT:
|
if user_profile.color_scheme == UserProfile.COLOR_SCHEME_NIGHT:
|
||||||
return dict(msg='You are still in night mode.')
|
return dict(msg='You are still in night mode.')
|
||||||
|
|
|
@ -239,7 +239,7 @@ class LogRequests(MiddlewareMixin):
|
||||||
# Avoid re-initializing request._log_data if it's already there.
|
# Avoid re-initializing request._log_data if it's already there.
|
||||||
return
|
return
|
||||||
|
|
||||||
request._log_data = dict()
|
request._log_data = {}
|
||||||
record_request_start_data(request._log_data)
|
record_request_start_data(request._log_data)
|
||||||
|
|
||||||
def process_view(self, request: HttpRequest, view_func: ViewFuncT,
|
def process_view(self, request: HttpRequest, view_func: ViewFuncT,
|
||||||
|
|
|
@ -30,7 +30,7 @@ def get_video_chat_provider_detail(providers_dict: Dict[str, Dict[str, Any]],
|
||||||
return provider
|
return provider
|
||||||
if (p_id and provider['id'] == p_id):
|
if (p_id and provider['id'] == p_id):
|
||||||
return provider
|
return provider
|
||||||
return dict()
|
return {}
|
||||||
|
|
||||||
def update_existing_video_chat_provider_values(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
|
def update_existing_video_chat_provider_values(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
|
||||||
Realm = apps.get_model('zerver', 'Realm')
|
Realm = apps.get_model('zerver', 'Realm')
|
||||||
|
|
|
@ -28,7 +28,7 @@ def move_back_to_user_profile(apps: StateApps, schema_editor: DatabaseSchemaEdit
|
||||||
UserProfile = apps.get_model('zerver', 'UserProfile')
|
UserProfile = apps.get_model('zerver', 'UserProfile')
|
||||||
|
|
||||||
user_ids_and_words = AlertWord.objects.all().values("user_profile_id", "word")
|
user_ids_and_words = AlertWord.objects.all().values("user_profile_id", "word")
|
||||||
user_ids_with_words: Dict[int, List[str]] = dict()
|
user_ids_with_words: Dict[int, List[str]] = {}
|
||||||
|
|
||||||
for id_and_word in user_ids_and_words:
|
for id_and_word in user_ids_and_words:
|
||||||
user_ids_with_words.setdefault(id_and_word["user_profile_id"], [])
|
user_ids_with_words.setdefault(id_and_word["user_profile_id"], [])
|
||||||
|
|
|
@ -8,7 +8,7 @@ from zerver.lib.events import do_events_register
|
||||||
from zerver.lib.test_classes import ZulipTestCase
|
from zerver.lib.test_classes import ZulipTestCase
|
||||||
from zerver.models import Client, Message, UserGroup, UserPresence, get_realm
|
from zerver.models import Client, Message, UserGroup, UserPresence, get_realm
|
||||||
|
|
||||||
GENERATOR_FUNCTIONS: Dict[str, Callable[[], Dict[str, object]]] = dict()
|
GENERATOR_FUNCTIONS: Dict[str, Callable[[], Dict[str, object]]] = {}
|
||||||
REGISTERED_GENERATOR_FUNCTIONS: Set[str] = set()
|
REGISTERED_GENERATOR_FUNCTIONS: Set[str] = set()
|
||||||
CALLED_GENERATOR_FUNCTIONS: Set[str] = set()
|
CALLED_GENERATOR_FUNCTIONS: Set[str] = set()
|
||||||
|
|
||||||
|
|
|
@ -306,7 +306,7 @@ def render_curl_example(function: str, api_url: str,
|
||||||
parts = function.split(":")
|
parts = function.split(":")
|
||||||
endpoint = parts[0]
|
endpoint = parts[0]
|
||||||
method = parts[1]
|
method = parts[1]
|
||||||
kwargs: Dict[str, Any] = dict()
|
kwargs: Dict[str, Any] = {}
|
||||||
if len(parts) > 2:
|
if len(parts) > 2:
|
||||||
kwargs["auth_email"] = parts[2]
|
kwargs["auth_email"] = parts[2]
|
||||||
if len(parts) > 3:
|
if len(parts) > 3:
|
||||||
|
|
|
@ -266,7 +266,7 @@ def validate_schema(schema: Dict[str, Any]) -> None:
|
||||||
if 'additionalProperties' not in schema:
|
if 'additionalProperties' not in schema:
|
||||||
raise SchemaError('additionalProperties needs to be defined for objects to make' +
|
raise SchemaError('additionalProperties needs to be defined for objects to make' +
|
||||||
'sure they have no additional properties left to be documented.')
|
'sure they have no additional properties left to be documented.')
|
||||||
for property_schema in schema.get('properties', dict()).values():
|
for property_schema in schema.get('properties', {}).values():
|
||||||
validate_schema(property_schema)
|
validate_schema(property_schema)
|
||||||
if schema['additionalProperties']:
|
if schema['additionalProperties']:
|
||||||
validate_schema(schema['additionalProperties'])
|
validate_schema(schema['additionalProperties'])
|
||||||
|
|
|
@ -12,7 +12,7 @@ from zerver.openapi.openapi import validate_against_openapi_schema
|
||||||
|
|
||||||
ZULIP_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
ZULIP_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
|
||||||
TEST_FUNCTIONS: Dict[str, Callable[..., object]] = dict()
|
TEST_FUNCTIONS: Dict[str, Callable[..., object]] = {}
|
||||||
REGISTERED_TEST_FUNCTIONS: Set[str] = set()
|
REGISTERED_TEST_FUNCTIONS: Set[str] = set()
|
||||||
CALLED_TEST_FUNCTIONS: Set[str] = set()
|
CALLED_TEST_FUNCTIONS: Set[str] = set()
|
||||||
|
|
||||||
|
|
|
@ -255,23 +255,23 @@ class AuthBackendTest(ZulipTestCase):
|
||||||
password=password,
|
password=password,
|
||||||
username=username,
|
username=username,
|
||||||
realm=get_realm('zulip'),
|
realm=get_realm('zulip'),
|
||||||
return_data=dict()),
|
return_data={}),
|
||||||
bad_kwargs=dict(request=mock.MagicMock(),
|
bad_kwargs=dict(request=mock.MagicMock(),
|
||||||
password=password,
|
password=password,
|
||||||
username=username,
|
username=username,
|
||||||
realm=get_realm('zephyr'),
|
realm=get_realm('zephyr'),
|
||||||
return_data=dict()))
|
return_data={}))
|
||||||
self.verify_backend(EmailAuthBackend(),
|
self.verify_backend(EmailAuthBackend(),
|
||||||
good_kwargs=dict(request=mock.MagicMock(),
|
good_kwargs=dict(request=mock.MagicMock(),
|
||||||
password=password,
|
password=password,
|
||||||
username=username,
|
username=username,
|
||||||
realm=get_realm('zulip'),
|
realm=get_realm('zulip'),
|
||||||
return_data=dict()),
|
return_data={}),
|
||||||
bad_kwargs=dict(request=mock.MagicMock(),
|
bad_kwargs=dict(request=mock.MagicMock(),
|
||||||
password=password,
|
password=password,
|
||||||
username=username,
|
username=username,
|
||||||
realm=get_realm('zephyr'),
|
realm=get_realm('zephyr'),
|
||||||
return_data=dict()))
|
return_data={}))
|
||||||
|
|
||||||
def test_email_auth_backend_empty_password(self) -> None:
|
def test_email_auth_backend_empty_password(self) -> None:
|
||||||
user_profile = self.example_user('hamlet')
|
user_profile = self.example_user('hamlet')
|
||||||
|
@ -600,7 +600,7 @@ class RateLimitAuthenticationTests(ZulipTestCase):
|
||||||
username=username,
|
username=username,
|
||||||
realm=get_realm("zulip"),
|
realm=get_realm("zulip"),
|
||||||
password=password,
|
password=password,
|
||||||
return_data=dict())
|
return_data={})
|
||||||
|
|
||||||
self.do_test_auth_rate_limiting(attempt_authentication,
|
self.do_test_auth_rate_limiting(attempt_authentication,
|
||||||
user_profile.delivery_email,
|
user_profile.delivery_email,
|
||||||
|
@ -619,7 +619,7 @@ class RateLimitAuthenticationTests(ZulipTestCase):
|
||||||
username=username,
|
username=username,
|
||||||
realm=get_realm("zulip"),
|
realm=get_realm("zulip"),
|
||||||
password=password,
|
password=password,
|
||||||
return_data=dict())
|
return_data={})
|
||||||
|
|
||||||
self.do_test_auth_rate_limiting(attempt_authentication,
|
self.do_test_auth_rate_limiting(attempt_authentication,
|
||||||
user_profile.delivery_email,
|
user_profile.delivery_email,
|
||||||
|
@ -643,7 +643,7 @@ class RateLimitAuthenticationTests(ZulipTestCase):
|
||||||
username=username,
|
username=username,
|
||||||
realm=get_realm("zulip"),
|
realm=get_realm("zulip"),
|
||||||
password=password,
|
password=password,
|
||||||
return_data=dict())
|
return_data={})
|
||||||
|
|
||||||
self.do_test_auth_rate_limiting(attempt_authentication,
|
self.do_test_auth_rate_limiting(attempt_authentication,
|
||||||
user_profile.delivery_email,
|
user_profile.delivery_email,
|
||||||
|
|
|
@ -274,7 +274,7 @@ class IntegrationTest(ZulipTestCase):
|
||||||
self.assertTrue(os.path.isfile(settings.DEPLOY_ROOT + path), integration.name)
|
self.assertTrue(os.path.isfile(settings.DEPLOY_ROOT + path), integration.name)
|
||||||
|
|
||||||
def test_api_url_view_subdomains_base(self) -> None:
|
def test_api_url_view_subdomains_base(self) -> None:
|
||||||
context: Dict[str, Any] = dict()
|
context: Dict[str, Any] = {}
|
||||||
add_api_uri_context(context, HostRequestMock())
|
add_api_uri_context(context, HostRequestMock())
|
||||||
self.assertEqual(context["api_url_scheme_relative"], "testserver/api")
|
self.assertEqual(context["api_url_scheme_relative"], "testserver/api")
|
||||||
self.assertEqual(context["api_url"], "http://testserver/api")
|
self.assertEqual(context["api_url"], "http://testserver/api")
|
||||||
|
@ -282,14 +282,14 @@ class IntegrationTest(ZulipTestCase):
|
||||||
|
|
||||||
@override_settings(ROOT_DOMAIN_LANDING_PAGE=True)
|
@override_settings(ROOT_DOMAIN_LANDING_PAGE=True)
|
||||||
def test_api_url_view_subdomains_homepage_base(self) -> None:
|
def test_api_url_view_subdomains_homepage_base(self) -> None:
|
||||||
context: Dict[str, Any] = dict()
|
context: Dict[str, Any] = {}
|
||||||
add_api_uri_context(context, HostRequestMock())
|
add_api_uri_context(context, HostRequestMock())
|
||||||
self.assertEqual(context["api_url_scheme_relative"], "yourZulipDomain.testserver/api")
|
self.assertEqual(context["api_url_scheme_relative"], "yourZulipDomain.testserver/api")
|
||||||
self.assertEqual(context["api_url"], "http://yourZulipDomain.testserver/api")
|
self.assertEqual(context["api_url"], "http://yourZulipDomain.testserver/api")
|
||||||
self.assertFalse(context["html_settings_links"])
|
self.assertFalse(context["html_settings_links"])
|
||||||
|
|
||||||
def test_api_url_view_subdomains_full(self) -> None:
|
def test_api_url_view_subdomains_full(self) -> None:
|
||||||
context: Dict[str, Any] = dict()
|
context: Dict[str, Any] = {}
|
||||||
request = HostRequestMock(host="mysubdomain.testserver")
|
request = HostRequestMock(host="mysubdomain.testserver")
|
||||||
add_api_uri_context(context, request)
|
add_api_uri_context(context, request)
|
||||||
self.assertEqual(context["api_url_scheme_relative"], "mysubdomain.testserver/api")
|
self.assertEqual(context["api_url_scheme_relative"], "mysubdomain.testserver/api")
|
||||||
|
@ -297,7 +297,7 @@ class IntegrationTest(ZulipTestCase):
|
||||||
self.assertTrue(context["html_settings_links"])
|
self.assertTrue(context["html_settings_links"])
|
||||||
|
|
||||||
def test_html_settings_links(self) -> None:
|
def test_html_settings_links(self) -> None:
|
||||||
context: Dict[str, Any] = dict()
|
context: Dict[str, Any] = {}
|
||||||
with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
|
with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
|
||||||
add_api_uri_context(context, HostRequestMock())
|
add_api_uri_context(context, HostRequestMock())
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
@ -307,7 +307,7 @@ class IntegrationTest(ZulipTestCase):
|
||||||
context['subscriptions_html'],
|
context['subscriptions_html'],
|
||||||
'streams page')
|
'streams page')
|
||||||
|
|
||||||
context = dict()
|
context = {}
|
||||||
with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
|
with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
|
||||||
add_api_uri_context(context, HostRequestMock(host="mysubdomain.testserver"))
|
add_api_uri_context(context, HostRequestMock(host="mysubdomain.testserver"))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
@ -317,7 +317,7 @@ class IntegrationTest(ZulipTestCase):
|
||||||
context['subscriptions_html'],
|
context['subscriptions_html'],
|
||||||
'<a target="_blank" href="/#streams">streams page</a>')
|
'<a target="_blank" href="/#streams">streams page</a>')
|
||||||
|
|
||||||
context = dict()
|
context = {}
|
||||||
add_api_uri_context(context, HostRequestMock())
|
add_api_uri_context(context, HostRequestMock())
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
context['settings_html'],
|
context['settings_html'],
|
||||||
|
|
|
@ -47,7 +47,7 @@ class EditMessageTest(ZulipTestCase):
|
||||||
(fetch_message_dict,) = messages_for_ids(
|
(fetch_message_dict,) = messages_for_ids(
|
||||||
message_ids = [msg.id],
|
message_ids = [msg.id],
|
||||||
user_message_flags={msg_id: []},
|
user_message_flags={msg_id: []},
|
||||||
search_fields=dict(),
|
search_fields={},
|
||||||
apply_markdown=False,
|
apply_markdown=False,
|
||||||
client_gravatar=False,
|
client_gravatar=False,
|
||||||
allow_edit_history=True,
|
allow_edit_history=True,
|
||||||
|
|
|
@ -1151,7 +1151,7 @@ class GetOldMessagesTest(ZulipTestCase):
|
||||||
Test old `/json/messages` returns reactions.
|
Test old `/json/messages` returns reactions.
|
||||||
"""
|
"""
|
||||||
self.login('hamlet')
|
self.login('hamlet')
|
||||||
messages = self.get_and_check_messages(dict())
|
messages = self.get_and_check_messages({})
|
||||||
message_id = messages['messages'][0]['id']
|
message_id = messages['messages'][0]['id']
|
||||||
|
|
||||||
self.login('othello')
|
self.login('othello')
|
||||||
|
@ -1182,7 +1182,7 @@ class GetOldMessagesTest(ZulipTestCase):
|
||||||
messages.
|
messages.
|
||||||
"""
|
"""
|
||||||
self.login('hamlet')
|
self.login('hamlet')
|
||||||
self.get_and_check_messages(dict())
|
self.get_and_check_messages({})
|
||||||
|
|
||||||
othello_email = self.example_user('othello').email
|
othello_email = self.example_user('othello').email
|
||||||
|
|
||||||
|
|
|
@ -507,7 +507,7 @@ class GetUnreadMsgsTest(ZulipTestCase):
|
||||||
self.subscribe(cordelia, stream_name)
|
self.subscribe(cordelia, stream_name)
|
||||||
|
|
||||||
all_message_ids: Set[int] = set()
|
all_message_ids: Set[int] = set()
|
||||||
message_ids = dict()
|
message_ids = {}
|
||||||
|
|
||||||
tups = [
|
tups = [
|
||||||
('social', 'lunch'),
|
('social', 'lunch'),
|
||||||
|
|
|
@ -21,7 +21,7 @@ class TopicHistoryTest(ZulipTestCase):
|
||||||
self.login_user(user_profile)
|
self.login_user(user_profile)
|
||||||
self.subscribe(user_profile, stream_name)
|
self.subscribe(user_profile, stream_name)
|
||||||
endpoint = f'/json/users/me/{stream.id}/topics'
|
endpoint = f'/json/users/me/{stream.id}/topics'
|
||||||
result = self.client_get(endpoint, dict(), subdomain="zephyr")
|
result = self.client_get(endpoint, {}, subdomain="zephyr")
|
||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
history = result.json()['topics']
|
history = result.json()['topics']
|
||||||
self.assertEqual(history, [])
|
self.assertEqual(history, [])
|
||||||
|
@ -75,7 +75,7 @@ class TopicHistoryTest(ZulipTestCase):
|
||||||
topic0_msg_id = create_test_message('topic0')
|
topic0_msg_id = create_test_message('topic0')
|
||||||
|
|
||||||
endpoint = f'/json/users/me/{stream.id}/topics'
|
endpoint = f'/json/users/me/{stream.id}/topics'
|
||||||
result = self.client_get(endpoint, dict())
|
result = self.client_get(endpoint, {})
|
||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
history = result.json()['topics']
|
history = result.json()['topics']
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ class TopicHistoryTest(ZulipTestCase):
|
||||||
# that she doesn't have UserMessage rows. We should see the
|
# that she doesn't have UserMessage rows. We should see the
|
||||||
# same results for a public stream.
|
# same results for a public stream.
|
||||||
self.login('cordelia')
|
self.login('cordelia')
|
||||||
result = self.client_get(endpoint, dict())
|
result = self.client_get(endpoint, {})
|
||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
history = result.json()['topics']
|
history = result.json()['topics']
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ class TopicHistoryTest(ZulipTestCase):
|
||||||
do_change_stream_invite_only(stream, True)
|
do_change_stream_invite_only(stream, True)
|
||||||
self.subscribe(self.example_user("cordelia"), stream.name)
|
self.subscribe(self.example_user("cordelia"), stream.name)
|
||||||
|
|
||||||
result = self.client_get(endpoint, dict())
|
result = self.client_get(endpoint, {})
|
||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
history = result.json()['topics']
|
history = result.json()['topics']
|
||||||
history = history[:3]
|
history = history[:3]
|
||||||
|
@ -140,7 +140,7 @@ class TopicHistoryTest(ZulipTestCase):
|
||||||
|
|
||||||
# non-sensible stream id
|
# non-sensible stream id
|
||||||
endpoint = '/json/users/me/9999999999/topics'
|
endpoint = '/json/users/me/9999999999/topics'
|
||||||
result = self.client_get(endpoint, dict())
|
result = self.client_get(endpoint, {})
|
||||||
self.assert_json_error(result, 'Invalid stream id')
|
self.assert_json_error(result, 'Invalid stream id')
|
||||||
|
|
||||||
# out of realm
|
# out of realm
|
||||||
|
@ -149,7 +149,7 @@ class TopicHistoryTest(ZulipTestCase):
|
||||||
realm=get_realm('zephyr'),
|
realm=get_realm('zephyr'),
|
||||||
)
|
)
|
||||||
endpoint = f'/json/users/me/{bad_stream.id}/topics'
|
endpoint = f'/json/users/me/{bad_stream.id}/topics'
|
||||||
result = self.client_get(endpoint, dict())
|
result = self.client_get(endpoint, {})
|
||||||
self.assert_json_error(result, 'Invalid stream id')
|
self.assert_json_error(result, 'Invalid stream id')
|
||||||
|
|
||||||
# private stream to which I am not subscribed
|
# private stream to which I am not subscribed
|
||||||
|
@ -158,7 +158,7 @@ class TopicHistoryTest(ZulipTestCase):
|
||||||
invite_only=True,
|
invite_only=True,
|
||||||
)
|
)
|
||||||
endpoint = f'/json/users/me/{private_stream.id}/topics'
|
endpoint = f'/json/users/me/{private_stream.id}/topics'
|
||||||
result = self.client_get(endpoint, dict())
|
result = self.client_get(endpoint, {})
|
||||||
self.assert_json_error(result, 'Invalid stream id')
|
self.assert_json_error(result, 'Invalid stream id')
|
||||||
|
|
||||||
class TopicDeleteTest(ZulipTestCase):
|
class TopicDeleteTest(ZulipTestCase):
|
||||||
|
|
|
@ -19,7 +19,7 @@ class MirroredMessageUsersTest(ZulipTestCase):
|
||||||
recipients: List[str] = []
|
recipients: List[str] = []
|
||||||
|
|
||||||
Request = namedtuple('Request', ['POST'])
|
Request = namedtuple('Request', ['POST'])
|
||||||
request = Request(POST=dict()) # no sender
|
request = Request(POST={}) # no sender
|
||||||
|
|
||||||
with self.assertRaises(InvalidMirrorInput):
|
with self.assertRaises(InvalidMirrorInput):
|
||||||
create_mirrored_message_users(request, user, recipients)
|
create_mirrored_message_users(request, user, recipients)
|
||||||
|
|
|
@ -433,7 +433,7 @@ do not match the types declared in the implementation of {function.__name__}.\n"
|
||||||
Otherwise, we print out the exact differences for convenient debugging and raise an
|
Otherwise, we print out the exact differences for convenient debugging and raise an
|
||||||
AssertionError. """
|
AssertionError. """
|
||||||
openapi_params: Set[Tuple[str, Union[type, Tuple[type, object]]]] = set()
|
openapi_params: Set[Tuple[str, Union[type, Tuple[type, object]]]] = set()
|
||||||
json_params: Dict[str, Union[type, Tuple[type, object]]] = dict()
|
json_params: Dict[str, Union[type, Tuple[type, object]]] = {}
|
||||||
for element in openapi_parameters:
|
for element in openapi_parameters:
|
||||||
name: str = element["name"]
|
name: str = element["name"]
|
||||||
schema = {}
|
schema = {}
|
||||||
|
|
|
@ -137,7 +137,7 @@ class TestGenericOutgoingWebhookService(ZulipTestCase):
|
||||||
)
|
)
|
||||||
self.assertEqual(success_response, expected_response)
|
self.assertEqual(success_response, expected_response)
|
||||||
|
|
||||||
response = dict()
|
response = {}
|
||||||
success_response = self.handler.process_success(response)
|
success_response = self.handler.process_success(response)
|
||||||
self.assertEqual(success_response, None)
|
self.assertEqual(success_response, None)
|
||||||
|
|
||||||
|
|
|
@ -343,7 +343,7 @@ class TestServiceBotConfigHandler(ZulipTestCase):
|
||||||
with self.assertRaises(ConfigError):
|
with self.assertRaises(ConfigError):
|
||||||
self.bot_handler.get_config_info('foo')
|
self.bot_handler.get_config_info('foo')
|
||||||
|
|
||||||
self.assertEqual(self.bot_handler.get_config_info('foo', optional=True), dict())
|
self.assertEqual(self.bot_handler.get_config_info('foo', optional=True), {})
|
||||||
|
|
||||||
config_dict = {"entry 1": "value 1", "entry 2": "value 2"}
|
config_dict = {"entry 1": "value 1", "entry 2": "value 2"}
|
||||||
for key, value in config_dict.items():
|
for key, value in config_dict.items():
|
||||||
|
|
|
@ -759,7 +759,7 @@ class LoginTest(ZulipTestCase):
|
||||||
self.assertEqual(response["Location"], "http://zulip.testserver")
|
self.assertEqual(response["Location"], "http://zulip.testserver")
|
||||||
|
|
||||||
def test_start_two_factor_auth(self) -> None:
|
def test_start_two_factor_auth(self) -> None:
|
||||||
request = MagicMock(POST=dict())
|
request = MagicMock(POST={})
|
||||||
with patch('zerver.views.auth.TwoFactorLoginView') as mock_view:
|
with patch('zerver.views.auth.TwoFactorLoginView') as mock_view:
|
||||||
mock_view.as_view.return_value = lambda *a, **k: HttpResponse()
|
mock_view.as_view.return_value = lambda *a, **k: HttpResponse()
|
||||||
response = start_two_factor_auth(request)
|
response = start_two_factor_auth(request)
|
||||||
|
|
|
@ -627,7 +627,7 @@ class SlackImporter(ZulipTestCase):
|
||||||
dm_members = {'DJ47BL849': ('U066MTL5U', 'U061A5N1G'), 'DHX1UP7EG': ('U061A5N1G', 'U061A1R2R')}
|
dm_members = {'DJ47BL849': ('U066MTL5U', 'U061A5N1G'), 'DHX1UP7EG': ('U061A5N1G', 'U061A1R2R')}
|
||||||
|
|
||||||
zerver_usermessage: List[Dict[str, Any]] = []
|
zerver_usermessage: List[Dict[str, Any]] = []
|
||||||
subscriber_map: Dict[int, Set[int]] = dict()
|
subscriber_map: Dict[int, Set[int]] = {}
|
||||||
added_channels: Dict[str, Tuple[str, int]] = {'random': ('c5', 1), 'general': ('c6', 2)}
|
added_channels: Dict[str, Tuple[str, int]] = {'random': ('c5', 1), 'general': ('c6', 2)}
|
||||||
|
|
||||||
zerver_message, zerver_usermessage, attachment, uploads, reaction = \
|
zerver_message, zerver_usermessage, attachment, uploads, reaction = \
|
||||||
|
|
|
@ -19,7 +19,7 @@ def get_away_user_ids(realm_id: int) -> Set[int]:
|
||||||
|
|
||||||
def user_info(user: UserProfile) -> Dict[str, Any]:
|
def user_info(user: UserProfile) -> Dict[str, Any]:
|
||||||
user_dict = get_user_info_dict(user.realm_id)
|
user_dict = get_user_info_dict(user.realm_id)
|
||||||
return user_dict.get(str(user.id), dict())
|
return user_dict.get(str(user.id), {})
|
||||||
|
|
||||||
class UserStatusTest(ZulipTestCase):
|
class UserStatusTest(ZulipTestCase):
|
||||||
def test_basics(self) -> None:
|
def test_basics(self) -> None:
|
||||||
|
@ -92,7 +92,7 @@ class UserStatusTest(ZulipTestCase):
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
user_info(hamlet),
|
user_info(hamlet),
|
||||||
dict(),
|
{},
|
||||||
)
|
)
|
||||||
|
|
||||||
away_user_ids = get_away_user_ids(realm_id=realm_id)
|
away_user_ids = get_away_user_ids(realm_id=realm_id)
|
||||||
|
@ -148,7 +148,7 @@ class UserStatusTest(ZulipTestCase):
|
||||||
self.login_user(hamlet)
|
self.login_user(hamlet)
|
||||||
|
|
||||||
# Try to omit parameter--this should be an error.
|
# Try to omit parameter--this should be an error.
|
||||||
payload: Dict[str, Any] = dict()
|
payload: Dict[str, Any] = {}
|
||||||
result = self.client_post('/json/users/me/status', payload)
|
result = self.client_post('/json/users/me/status', payload)
|
||||||
self.assert_json_error(result, "Client did not pass any new values.")
|
self.assert_json_error(result, "Client did not pass any new values.")
|
||||||
|
|
||||||
|
|
|
@ -768,7 +768,7 @@ class AdminCreateUserTest(ZulipTestCase):
|
||||||
self.login_user(admin)
|
self.login_user(admin)
|
||||||
do_change_user_role(admin, UserProfile.ROLE_REALM_ADMINISTRATOR)
|
do_change_user_role(admin, UserProfile.ROLE_REALM_ADMINISTRATOR)
|
||||||
|
|
||||||
result = self.client_post("/json/users", dict())
|
result = self.client_post("/json/users", {})
|
||||||
self.assert_json_error(result, "Missing 'email' argument")
|
self.assert_json_error(result, "Missing 'email' argument")
|
||||||
|
|
||||||
result = self.client_post("/json/users", dict(
|
result = self.client_post("/json/users", dict(
|
||||||
|
|
|
@ -31,7 +31,7 @@ class WidgetContentTestCase(ZulipTestCase):
|
||||||
assert_error(dict(widget_type='bogus', extra_data={}),
|
assert_error(dict(widget_type='bogus', extra_data={}),
|
||||||
'unknown widget type: bogus')
|
'unknown widget type: bogus')
|
||||||
|
|
||||||
extra_data: Dict[str, Any] = dict()
|
extra_data: Dict[str, Any] = {}
|
||||||
obj = dict(widget_type='zform', extra_data=extra_data)
|
obj = dict(widget_type='zform', extra_data=extra_data)
|
||||||
|
|
||||||
assert_error(obj, 'zform is missing type field')
|
assert_error(obj, 'zform is missing type field')
|
||||||
|
|
|
@ -687,7 +687,7 @@ def maybe_enqueue_notifications(user_profile_id: int, message_id: int, private_m
|
||||||
"""This function has a complete unit test suite in
|
"""This function has a complete unit test suite in
|
||||||
`test_enqueue_notifications` that should be expanded as we add
|
`test_enqueue_notifications` that should be expanded as we add
|
||||||
more features here."""
|
more features here."""
|
||||||
notified: Dict[str, bool] = dict()
|
notified: Dict[str, bool] = {}
|
||||||
|
|
||||||
if (idle or always_push_notify) and (private_message or mentioned or
|
if (idle or always_push_notify) and (private_message or mentioned or
|
||||||
wildcard_mention_notify or stream_push_notify):
|
wildcard_mention_notify or stream_push_notify):
|
||||||
|
|
|
@ -1024,7 +1024,7 @@ def get_messages_backend(request: HttpRequest,
|
||||||
user_message_flags[message_id] = UserMessage.flags_list_for_flags(flags)
|
user_message_flags[message_id] = UserMessage.flags_list_for_flags(flags)
|
||||||
message_ids.append(message_id)
|
message_ids.append(message_id)
|
||||||
|
|
||||||
search_fields: Dict[int, Dict[str, str]] = dict()
|
search_fields: Dict[int, Dict[str, str]] = {}
|
||||||
if is_search:
|
if is_search:
|
||||||
for row in rows:
|
for row in rows:
|
||||||
message_id = row[0]
|
message_id = row[0]
|
||||||
|
@ -1231,7 +1231,7 @@ def messages_in_narrow_backend(request: HttpRequest, user_profile: UserProfile,
|
||||||
sa_conn = get_sqlalchemy_connection()
|
sa_conn = get_sqlalchemy_connection()
|
||||||
query_result = list(sa_conn.execute(query).fetchall())
|
query_result = list(sa_conn.execute(query).fetchall())
|
||||||
|
|
||||||
search_fields = dict()
|
search_fields = {}
|
||||||
for row in query_result:
|
for row in query_result:
|
||||||
message_id = row['message_id']
|
message_id = row['message_id']
|
||||||
topic_name = row[DB_TOPIC_NAME]
|
topic_name = row[DB_TOPIC_NAME]
|
||||||
|
|
|
@ -476,7 +476,7 @@ def add_subscriptions_backend(
|
||||||
|
|
||||||
# We can assume unique emails here for now, but we should eventually
|
# We can assume unique emails here for now, but we should eventually
|
||||||
# convert this function to be more id-centric.
|
# convert this function to be more id-centric.
|
||||||
email_to_user_profile: Dict[str, UserProfile] = dict()
|
email_to_user_profile: Dict[str, UserProfile] = {}
|
||||||
|
|
||||||
result: Dict[str, Any] = dict(subscribed=defaultdict(list), already_subscribed=defaultdict(list))
|
result: Dict[str, Any] = dict(subscribed=defaultdict(list), already_subscribed=defaultdict(list))
|
||||||
for (subscriber, stream) in subscribed:
|
for (subscriber, stream) in subscribed:
|
||||||
|
|
|
@ -51,7 +51,7 @@ PULL_REQUEST_OPENED_OR_MODIFIED_TEMPLATE_WITH_REVIEWERS_WITH_TITLE = """
|
||||||
def fixture_to_headers(fixture_name: str) -> Dict[str, str]:
|
def fixture_to_headers(fixture_name: str) -> Dict[str, str]:
|
||||||
if fixture_name == "diagnostics_ping":
|
if fixture_name == "diagnostics_ping":
|
||||||
return {"HTTP_X_EVENT_KEY": "diagnostics:ping"}
|
return {"HTTP_X_EVENT_KEY": "diagnostics:ping"}
|
||||||
return dict()
|
return {}
|
||||||
|
|
||||||
def get_user_name(payload: Dict[str, Any]) -> str:
|
def get_user_name(payload: Dict[str, Any]) -> str:
|
||||||
user_name = "[{name}]({url})".format(name=payload["actor"]["name"],
|
user_name = "[{name}]({url})".format(name=payload["actor"]["name"],
|
||||||
|
|
|
@ -715,7 +715,7 @@ def generate_and_send_messages(data: Tuple[int, Sequence[Sequence[int]], Mapping
|
||||||
Subscription.objects.filter(recipient_id=h)]
|
Subscription.objects.filter(recipient_id=h)]
|
||||||
|
|
||||||
# Generate different topics for each stream
|
# Generate different topics for each stream
|
||||||
possible_topics = dict()
|
possible_topics = {}
|
||||||
for stream_id in recipient_streams:
|
for stream_id in recipient_streams:
|
||||||
possible_topics[stream_id] = generate_topics(options["max_topics"])
|
possible_topics[stream_id] = generate_topics(options["max_topics"])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue