python: Rewrite dict() as {}.

Suggested by the flake8-comprehensions plugin.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-09-01 23:14:51 -07:00 committed by Tim Abbott
parent a610bd19a1
commit a276eefcfe
46 changed files with 79 additions and 79 deletions

View File

@ -155,7 +155,7 @@ def check_rabbitmq_queues() -> None:
list_consumers_output = subprocess.check_output(['/usr/sbin/rabbitmqctl', 'list_consumers'],
universal_newlines=True)
queue_counts_rabbitmqctl = dict()
queue_counts_rabbitmqctl = {}
for line in list_queues_output.split("\n"):
line = line.strip()
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'],
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))
for queue in queues_to_check:
fn = queue + ".stats"

View File

@ -124,7 +124,7 @@ def create_user_docs() -> None:
('json', 'legacy'),
]
groups: Dict[str, Set[str]] = dict()
groups: Dict[str, Set[str]] = {}
for prefix, name in tups:
groups[name] = {p for p in patterns if p.startswith(prefix)}
patterns -= groups[name]

View File

@ -661,7 +661,7 @@ def process_raw_message_batch(realm_id: int,
content = content.replace('@here', '@**all**')
return content
mention_map: Dict[int, Set[int]] = dict()
mention_map: Dict[int, Set[int]] = {}
zerver_message = []

View File

@ -8,7 +8,7 @@ from zerver.data_import.import_util import build_attachment, create_converted_da
class AttachmentHandler:
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,
realm_id: int,

View File

@ -20,8 +20,8 @@ class UserHandler:
'''
def __init__(self) -> None:
self.id_to_user_map: Dict[int, Dict[str, Any]] = dict()
self.name_to_mirror_user_map: Dict[str, 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]] = {}
self.mirror_user_id = 1
def add_user(self, user: Dict[str, Any]) -> None:

View File

@ -41,8 +41,8 @@ ZerverFieldsT = Dict[str, Any]
class SubscriberHandler:
def __init__(self) -> None:
self.stream_info: Dict[int, Set[int]] = dict()
self.huddle_info: Dict[int, Set[int]] = dict()
self.stream_info: Dict[int, Set[int]] = {}
self.huddle_info: Dict[int, Set[int]] = {}
def set_info(self,
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
rows.
'''
subscriber_map: Dict[int, Set[int]] = dict()
subscriber_map: Dict[int, Set[int]] = {}
for sub in zerver_subscription:
user_id = sub['user_profile']
recipient_id = sub['recipient']

View File

@ -319,7 +319,7 @@ def process_raw_message_batch(realm_id: int,
content = content.replace('@here', '@**all**')
return content
mention_map: Dict[int, Set[int]] = dict()
mention_map: Dict[int, Set[int]] = {}
zerver_message = []
import html2text

View File

@ -12,7 +12,7 @@ class UserHandler:
'''
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:
user_id = user['id']

View File

@ -28,7 +28,7 @@ def sequencer() -> Callable[[str], int]:
NEXT_ID = sequencer()
message_id = NEXT_ID('message')
'''
seq_dict: Dict[str, Callable[[], int]] = dict()
seq_dict: Dict[str, Callable[[], int]] = {}
def next_one(name: str) -> int:
if name not in seq_dict:
@ -59,7 +59,7 @@ def is_int(key: Any) -> bool:
class IdMapper:
def __init__(self) -> None:
self.map: Dict[Any, int] = dict()
self.map: Dict[Any, int] = {}
self.cnt = 0
def has(self, their_id: Any) -> bool:

View File

@ -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]]:
user_ids_and_words = AlertWord.objects.filter(
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:
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"])

View File

@ -68,4 +68,4 @@ def load_bot_config_template(bot: str) -> Dict[str, str]:
config.read_file(conf)
return dict(config.items(bot))
else:
return dict()
return {}

View File

@ -125,7 +125,7 @@ class EmbeddedBotHandler:
return get_bot_config(self.user_profile)
except ConfigError:
if optional:
return dict()
return {}
raise
def quit(self, message: str= "") -> None:

View File

@ -810,7 +810,7 @@ def apply_event(state: Dict[str, Any],
status_text = event.get('status_text')
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:

View File

@ -754,7 +754,7 @@ class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor):
# and gifs do not work.
# TODO: What if image is huge? Should we get headers first?
if image_info is None:
image_info = dict()
image_info = {}
image_info['is_image'] = True
parsed_url_list = list(parsed_url)
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]:
if not user_group_names:
return dict()
return {}
rows = UserGroup.objects.filter(realm_id=realm_id,
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]:
if not stream_names:
return dict()
return {}
q_list = {
Q(name=name)
@ -2323,7 +2323,7 @@ def do_convert(content: str,
if content_has_emoji_syntax(content):
active_realm_emoji = message_realm.get_active_emoji()
else:
active_realm_emoji = dict()
active_realm_emoji = {}
_md_engine.zulip_db_data = {
'realm_alert_words_automaton': realm_alert_words_automaton,

View File

@ -730,7 +730,7 @@ def huddle_users(recipient_id: int) -> str:
def aggregate_message_dict(input_dict: Dict[int, Dict[str, Any]],
lookup_fields: List[str],
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:

View File

@ -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_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):
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
# keys for entities that have None values. JS
# code should just do a falsy check here.
result = dict()
result = {}
if active_timestamp is not None:
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]
result = dict()
result = {}
# The word "aggegrated" here is possibly misleading.
# It's really just the most recent client's info.

View File

@ -21,8 +21,8 @@ class StreamRecipientMap:
'''
def __init__(self) -> None:
self.recip_to_stream: Dict[int, int] = dict()
self.stream_to_recip: Dict[int, int] = dict()
self.recip_to_stream: Dict[int, int] = {}
self.stream_to_recip: Dict[int, int] = {}
def populate_with(self, *, stream_id: int, recipient_id: int) -> None:
# We use * to enforce using named arguments when calling this function,

View File

@ -19,13 +19,13 @@ def get_user_info_dict(realm_id: int) -> Dict[str, Dict[str, Any]]:
'status_text',
)
user_dict: Dict[str, Dict[str, Any]] = dict()
user_dict: Dict[str, Dict[str, Any]] = {}
for row in rows:
away = row['status'] == UserStatus.AWAY
status_text = row['status_text']
user_id = row['user_profile_id']
dct = dict()
dct = {}
if away:
dct['away'] = away
if status_text:

View File

@ -25,7 +25,7 @@ def process_zcommands(content: str, user_profile: UserProfile) -> Dict[str, Any]
command = content[1:]
if command == 'ping':
return dict()
return {}
elif command == 'night':
if user_profile.color_scheme == UserProfile.COLOR_SCHEME_NIGHT:
return dict(msg='You are still in night mode.')

View File

@ -239,7 +239,7 @@ class LogRequests(MiddlewareMixin):
# Avoid re-initializing request._log_data if it's already there.
return
request._log_data = dict()
request._log_data = {}
record_request_start_data(request._log_data)
def process_view(self, request: HttpRequest, view_func: ViewFuncT,

View File

@ -30,7 +30,7 @@ def get_video_chat_provider_detail(providers_dict: Dict[str, Dict[str, Any]],
return provider
if (p_id and provider['id'] == p_id):
return provider
return dict()
return {}
def update_existing_video_chat_provider_values(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
Realm = apps.get_model('zerver', 'Realm')

View File

@ -28,7 +28,7 @@ def move_back_to_user_profile(apps: StateApps, schema_editor: DatabaseSchemaEdit
UserProfile = apps.get_model('zerver', 'UserProfile')
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:
user_ids_with_words.setdefault(id_and_word["user_profile_id"], [])

View File

@ -8,7 +8,7 @@ from zerver.lib.events import do_events_register
from zerver.lib.test_classes import ZulipTestCase
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()
CALLED_GENERATOR_FUNCTIONS: Set[str] = set()

View File

@ -306,7 +306,7 @@ def render_curl_example(function: str, api_url: str,
parts = function.split(":")
endpoint = parts[0]
method = parts[1]
kwargs: Dict[str, Any] = dict()
kwargs: Dict[str, Any] = {}
if len(parts) > 2:
kwargs["auth_email"] = parts[2]
if len(parts) > 3:

View File

@ -266,7 +266,7 @@ def validate_schema(schema: Dict[str, Any]) -> None:
if 'additionalProperties' not in schema:
raise SchemaError('additionalProperties needs to be defined for objects to make' +
'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)
if schema['additionalProperties']:
validate_schema(schema['additionalProperties'])

View File

@ -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__))))
TEST_FUNCTIONS: Dict[str, Callable[..., object]] = dict()
TEST_FUNCTIONS: Dict[str, Callable[..., object]] = {}
REGISTERED_TEST_FUNCTIONS: Set[str] = set()
CALLED_TEST_FUNCTIONS: Set[str] = set()

View File

@ -255,23 +255,23 @@ class AuthBackendTest(ZulipTestCase):
password=password,
username=username,
realm=get_realm('zulip'),
return_data=dict()),
return_data={}),
bad_kwargs=dict(request=mock.MagicMock(),
password=password,
username=username,
realm=get_realm('zephyr'),
return_data=dict()))
return_data={}))
self.verify_backend(EmailAuthBackend(),
good_kwargs=dict(request=mock.MagicMock(),
password=password,
username=username,
realm=get_realm('zulip'),
return_data=dict()),
return_data={}),
bad_kwargs=dict(request=mock.MagicMock(),
password=password,
username=username,
realm=get_realm('zephyr'),
return_data=dict()))
return_data={}))
def test_email_auth_backend_empty_password(self) -> None:
user_profile = self.example_user('hamlet')
@ -600,7 +600,7 @@ class RateLimitAuthenticationTests(ZulipTestCase):
username=username,
realm=get_realm("zulip"),
password=password,
return_data=dict())
return_data={})
self.do_test_auth_rate_limiting(attempt_authentication,
user_profile.delivery_email,
@ -619,7 +619,7 @@ class RateLimitAuthenticationTests(ZulipTestCase):
username=username,
realm=get_realm("zulip"),
password=password,
return_data=dict())
return_data={})
self.do_test_auth_rate_limiting(attempt_authentication,
user_profile.delivery_email,
@ -643,7 +643,7 @@ class RateLimitAuthenticationTests(ZulipTestCase):
username=username,
realm=get_realm("zulip"),
password=password,
return_data=dict())
return_data={})
self.do_test_auth_rate_limiting(attempt_authentication,
user_profile.delivery_email,

View File

@ -274,7 +274,7 @@ class IntegrationTest(ZulipTestCase):
self.assertTrue(os.path.isfile(settings.DEPLOY_ROOT + path), integration.name)
def test_api_url_view_subdomains_base(self) -> None:
context: Dict[str, Any] = dict()
context: Dict[str, Any] = {}
add_api_uri_context(context, HostRequestMock())
self.assertEqual(context["api_url_scheme_relative"], "testserver/api")
self.assertEqual(context["api_url"], "http://testserver/api")
@ -282,14 +282,14 @@ class IntegrationTest(ZulipTestCase):
@override_settings(ROOT_DOMAIN_LANDING_PAGE=True)
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())
self.assertEqual(context["api_url_scheme_relative"], "yourZulipDomain.testserver/api")
self.assertEqual(context["api_url"], "http://yourZulipDomain.testserver/api")
self.assertFalse(context["html_settings_links"])
def test_api_url_view_subdomains_full(self) -> None:
context: Dict[str, Any] = dict()
context: Dict[str, Any] = {}
request = HostRequestMock(host="mysubdomain.testserver")
add_api_uri_context(context, request)
self.assertEqual(context["api_url_scheme_relative"], "mysubdomain.testserver/api")
@ -297,7 +297,7 @@ class IntegrationTest(ZulipTestCase):
self.assertTrue(context["html_settings_links"])
def test_html_settings_links(self) -> None:
context: Dict[str, Any] = dict()
context: Dict[str, Any] = {}
with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
add_api_uri_context(context, HostRequestMock())
self.assertEqual(
@ -307,7 +307,7 @@ class IntegrationTest(ZulipTestCase):
context['subscriptions_html'],
'streams page')
context = dict()
context = {}
with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
add_api_uri_context(context, HostRequestMock(host="mysubdomain.testserver"))
self.assertEqual(
@ -317,7 +317,7 @@ class IntegrationTest(ZulipTestCase):
context['subscriptions_html'],
'<a target="_blank" href="/#streams">streams page</a>')
context = dict()
context = {}
add_api_uri_context(context, HostRequestMock())
self.assertEqual(
context['settings_html'],

View File

@ -47,7 +47,7 @@ class EditMessageTest(ZulipTestCase):
(fetch_message_dict,) = messages_for_ids(
message_ids = [msg.id],
user_message_flags={msg_id: []},
search_fields=dict(),
search_fields={},
apply_markdown=False,
client_gravatar=False,
allow_edit_history=True,

View File

@ -1151,7 +1151,7 @@ class GetOldMessagesTest(ZulipTestCase):
Test old `/json/messages` returns reactions.
"""
self.login('hamlet')
messages = self.get_and_check_messages(dict())
messages = self.get_and_check_messages({})
message_id = messages['messages'][0]['id']
self.login('othello')
@ -1182,7 +1182,7 @@ class GetOldMessagesTest(ZulipTestCase):
messages.
"""
self.login('hamlet')
self.get_and_check_messages(dict())
self.get_and_check_messages({})
othello_email = self.example_user('othello').email

View File

@ -507,7 +507,7 @@ class GetUnreadMsgsTest(ZulipTestCase):
self.subscribe(cordelia, stream_name)
all_message_ids: Set[int] = set()
message_ids = dict()
message_ids = {}
tups = [
('social', 'lunch'),

View File

@ -21,7 +21,7 @@ class TopicHistoryTest(ZulipTestCase):
self.login_user(user_profile)
self.subscribe(user_profile, stream_name)
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)
history = result.json()['topics']
self.assertEqual(history, [])
@ -75,7 +75,7 @@ class TopicHistoryTest(ZulipTestCase):
topic0_msg_id = create_test_message('topic0')
endpoint = f'/json/users/me/{stream.id}/topics'
result = self.client_get(endpoint, dict())
result = self.client_get(endpoint, {})
self.assert_json_success(result)
history = result.json()['topics']
@ -99,7 +99,7 @@ class TopicHistoryTest(ZulipTestCase):
# that she doesn't have UserMessage rows. We should see the
# same results for a public stream.
self.login('cordelia')
result = self.client_get(endpoint, dict())
result = self.client_get(endpoint, {})
self.assert_json_success(result)
history = result.json()['topics']
@ -124,7 +124,7 @@ class TopicHistoryTest(ZulipTestCase):
do_change_stream_invite_only(stream, True)
self.subscribe(self.example_user("cordelia"), stream.name)
result = self.client_get(endpoint, dict())
result = self.client_get(endpoint, {})
self.assert_json_success(result)
history = result.json()['topics']
history = history[:3]
@ -140,7 +140,7 @@ class TopicHistoryTest(ZulipTestCase):
# non-sensible stream id
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')
# out of realm
@ -149,7 +149,7 @@ class TopicHistoryTest(ZulipTestCase):
realm=get_realm('zephyr'),
)
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')
# private stream to which I am not subscribed
@ -158,7 +158,7 @@ class TopicHistoryTest(ZulipTestCase):
invite_only=True,
)
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')
class TopicDeleteTest(ZulipTestCase):

View File

@ -19,7 +19,7 @@ class MirroredMessageUsersTest(ZulipTestCase):
recipients: List[str] = []
Request = namedtuple('Request', ['POST'])
request = Request(POST=dict()) # no sender
request = Request(POST={}) # no sender
with self.assertRaises(InvalidMirrorInput):
create_mirrored_message_users(request, user, recipients)

View File

@ -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
AssertionError. """
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:
name: str = element["name"]
schema = {}

View File

@ -137,7 +137,7 @@ class TestGenericOutgoingWebhookService(ZulipTestCase):
)
self.assertEqual(success_response, expected_response)
response = dict()
response = {}
success_response = self.handler.process_success(response)
self.assertEqual(success_response, None)

View File

@ -343,7 +343,7 @@ class TestServiceBotConfigHandler(ZulipTestCase):
with self.assertRaises(ConfigError):
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"}
for key, value in config_dict.items():

View File

@ -759,7 +759,7 @@ class LoginTest(ZulipTestCase):
self.assertEqual(response["Location"], "http://zulip.testserver")
def test_start_two_factor_auth(self) -> None:
request = MagicMock(POST=dict())
request = MagicMock(POST={})
with patch('zerver.views.auth.TwoFactorLoginView') as mock_view:
mock_view.as_view.return_value = lambda *a, **k: HttpResponse()
response = start_two_factor_auth(request)

View File

@ -627,7 +627,7 @@ class SlackImporter(ZulipTestCase):
dm_members = {'DJ47BL849': ('U066MTL5U', 'U061A5N1G'), 'DHX1UP7EG': ('U061A5N1G', 'U061A1R2R')}
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)}
zerver_message, zerver_usermessage, attachment, uploads, reaction = \

View File

@ -19,7 +19,7 @@ def get_away_user_ids(realm_id: int) -> Set[int]:
def user_info(user: UserProfile) -> Dict[str, Any]:
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):
def test_basics(self) -> None:
@ -92,7 +92,7 @@ class UserStatusTest(ZulipTestCase):
self.assertEqual(
user_info(hamlet),
dict(),
{},
)
away_user_ids = get_away_user_ids(realm_id=realm_id)
@ -148,7 +148,7 @@ class UserStatusTest(ZulipTestCase):
self.login_user(hamlet)
# 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)
self.assert_json_error(result, "Client did not pass any new values.")

View File

@ -768,7 +768,7 @@ class AdminCreateUserTest(ZulipTestCase):
self.login_user(admin)
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")
result = self.client_post("/json/users", dict(

View File

@ -31,7 +31,7 @@ class WidgetContentTestCase(ZulipTestCase):
assert_error(dict(widget_type='bogus', extra_data={}),
'unknown widget type: bogus')
extra_data: Dict[str, Any] = dict()
extra_data: Dict[str, Any] = {}
obj = dict(widget_type='zform', extra_data=extra_data)
assert_error(obj, 'zform is missing type field')

View File

@ -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
`test_enqueue_notifications` that should be expanded as we add
more features here."""
notified: Dict[str, bool] = dict()
notified: Dict[str, bool] = {}
if (idle or always_push_notify) and (private_message or mentioned or
wildcard_mention_notify or stream_push_notify):

View File

@ -1024,7 +1024,7 @@ def get_messages_backend(request: HttpRequest,
user_message_flags[message_id] = UserMessage.flags_list_for_flags(flags)
message_ids.append(message_id)
search_fields: Dict[int, Dict[str, str]] = dict()
search_fields: Dict[int, Dict[str, str]] = {}
if is_search:
for row in rows:
message_id = row[0]
@ -1231,7 +1231,7 @@ def messages_in_narrow_backend(request: HttpRequest, user_profile: UserProfile,
sa_conn = get_sqlalchemy_connection()
query_result = list(sa_conn.execute(query).fetchall())
search_fields = dict()
search_fields = {}
for row in query_result:
message_id = row['message_id']
topic_name = row[DB_TOPIC_NAME]

View File

@ -476,7 +476,7 @@ def add_subscriptions_backend(
# We can assume unique emails here for now, but we should eventually
# 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))
for (subscriber, stream) in subscribed:

View File

@ -51,7 +51,7 @@ PULL_REQUEST_OPENED_OR_MODIFIED_TEMPLATE_WITH_REVIEWERS_WITH_TITLE = """
def fixture_to_headers(fixture_name: str) -> Dict[str, str]:
if fixture_name == "diagnostics_ping":
return {"HTTP_X_EVENT_KEY": "diagnostics:ping"}
return dict()
return {}
def get_user_name(payload: Dict[str, Any]) -> str:
user_name = "[{name}]({url})".format(name=payload["actor"]["name"],

View File

@ -715,7 +715,7 @@ def generate_and_send_messages(data: Tuple[int, Sequence[Sequence[int]], Mapping
Subscription.objects.filter(recipient_id=h)]
# Generate different topics for each stream
possible_topics = dict()
possible_topics = {}
for stream_id in recipient_streams:
possible_topics[stream_id] = generate_topics(options["max_topics"])