lint: Add a rule to avoid msgid as a Python variable name.

This is for consistency with our usual patterns, see #12995.  We will
need a similar commit for JavaScript to complete #12995.
This commit is contained in:
okmanl 2019-08-14 23:05:44 -07:00 committed by Tim Abbott
parent dc191b0be4
commit 2a1305de9f
3 changed files with 15 additions and 11 deletions

View File

@ -227,6 +227,10 @@ python_rules = RuleList(
'zerver/lib/',
'zerver/tests/',
'zerver/views/'])},
{'pattern': 'msgid|MSGID',
'exclude': set(['tools/check-capitalization',
'tools/i18n/tagmessages']),
'description': 'Avoid using "msgid" as a variable name; use "message_id" instead.'},
{'pattern': '^(?!#)@login_required',
'description': '@login_required is unsupported; use @zulip_login_required',
'good_lines': ['@zulip_login_required', '# foo @login_required'],

View File

@ -51,12 +51,12 @@ def get_imap_messages() -> Generator[Message, None, None]:
mbox.select(settings.EMAIL_GATEWAY_IMAP_FOLDER)
try:
status, num_ids_data = mbox.search(None, 'ALL')
for msgid in num_ids_data[0].split():
status, msg_data = mbox.fetch(msgid, '(RFC822)')
for message_id in num_ids_data[0].split():
status, msg_data = mbox.fetch(message_id, '(RFC822)')
msg_as_bytes = msg_data[0][1]
message = email.message_from_bytes(msg_as_bytes)
yield message
mbox.store(msgid, '+FLAGS', '\\Deleted')
mbox.store(message_id, '+FLAGS', '\\Deleted')
mbox.expunge()
finally:
mbox.close()

View File

@ -1560,13 +1560,13 @@ class TestClearOnRead(ZulipTestCase):
hamlet.save()
stream = self.subscribe(hamlet, "Denmark")
msgids = [self.send_stream_message(self.example_email("iago"),
stream.name,
"yo {}".format(i))
for i in range(n_msgs)]
message_ids = [self.send_stream_message(self.example_email("iago"),
stream.name,
"yo {}".format(i))
for i in range(n_msgs)]
UserMessage.objects.filter(
user_profile_id=hamlet.id,
message_id__in=msgids,
message_id__in=message_ids,
).update(
flags=F('flags').bitor(
UserMessage.flags.active_mobile_push_notification))
@ -1577,11 +1577,11 @@ class TestClearOnRead(ZulipTestCase):
queue_items = [c[0][1] for c in mock_publish.call_args_list]
groups = [item['message_ids'] for item in queue_items]
self.assertEqual(len(groups), min(len(msgids), max_unbatched))
self.assertEqual(len(groups), min(len(message_ids), max_unbatched))
for g in groups[:-1]:
self.assertEqual(len(g), 1)
self.assertEqual(sum(len(g) for g in groups), len(msgids))
self.assertEqual(set(id for g in groups for id in g), set(msgids))
self.assertEqual(sum(len(g) for g in groups), len(message_ids))
self.assertEqual(set(id for g in groups for id in g), set(message_ids))
class TestReceivesNotificationsFunctions(ZulipTestCase):
def setUp(self) -> None: