mirror of https://github.com/zulip/zulip.git
style: Use 'not in' consistently rather than `not foo in`.
This commit is contained in:
parent
9cf18f8535
commit
b869be9301
|
@ -31,7 +31,7 @@ class Command(BaseCommand):
|
|||
known_active = last_presence.timestamp
|
||||
|
||||
for bucket in hour_buckets:
|
||||
if not bucket in user_info[last_presence.user_profile.realm.domain]:
|
||||
if bucket not in user_info[last_presence.user_profile.realm.domain]:
|
||||
user_info[last_presence.user_profile.realm.domain][bucket] = []
|
||||
if datetime.now(known_active.tzinfo) - known_active < timedelta(hours=bucket):
|
||||
user_info[last_presence.user_profile.realm.domain][bucket].append(last_presence.user_profile.email)
|
||||
|
@ -47,7 +47,7 @@ class Command(BaseCommand):
|
|||
user_info = defaultdict(dict)
|
||||
for activity in users_reading:
|
||||
for bucket in hour_buckets:
|
||||
if not bucket in user_info[activity.user_profile.realm.domain]:
|
||||
if bucket not in user_info[activity.user_profile.realm.domain]:
|
||||
user_info[activity.user_profile.realm.domain][bucket] = []
|
||||
if datetime.now(activity.last_visit.tzinfo) - activity.last_visit < timedelta(hours=bucket):
|
||||
user_info[activity.user_profile.realm.domain][bucket].append(activity.user_profile.email)
|
||||
|
|
|
@ -23,7 +23,7 @@ def add_user_alert_words(user_profile, alert_words):
|
|||
# type: (UserProfile, List[str]) -> List[str]
|
||||
words = user_alert_words(user_profile)
|
||||
|
||||
new_words = [w for w in alert_words if not w in words]
|
||||
new_words = [w for w in alert_words if w not in words]
|
||||
words.extend(new_words)
|
||||
|
||||
set_user_alert_words(user_profile, words)
|
||||
|
@ -33,7 +33,7 @@ def add_user_alert_words(user_profile, alert_words):
|
|||
def remove_user_alert_words(user_profile, alert_words):
|
||||
# type: (UserProfile, List[str]) -> List[str]
|
||||
words = user_alert_words(user_profile)
|
||||
words = [w for w in words if not w in alert_words]
|
||||
words = [w for w in words if w not in alert_words]
|
||||
|
||||
set_user_alert_words(user_profile, words)
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ def list_of_tlds():
|
|||
# tlds-alpha-by-domain.txt comes from http://data.iana.org/TLD/tlds-alpha-by-domain.txt
|
||||
tlds_file = os.path.join(os.path.dirname(__file__), 'tlds-alpha-by-domain.txt')
|
||||
tlds = [tld.lower().strip() for tld in open(tlds_file, 'r')
|
||||
if not tld in blacklist and not tld[0].startswith('#')]
|
||||
if tld not in blacklist and not tld[0].startswith('#')]
|
||||
tlds.sort(key=len, reverse=True)
|
||||
return tlds
|
||||
|
||||
|
@ -683,7 +683,7 @@ def url_to_a(url, text = None):
|
|||
|
||||
a.set('href', href)
|
||||
a.text = text
|
||||
fixup_link(a, not 'mailto:' in href[:7])
|
||||
fixup_link(a, 'mailto:' not in href[:7])
|
||||
return a
|
||||
|
||||
class AutoLink(markdown.inlinepatterns.Pattern):
|
||||
|
|
|
@ -575,7 +575,7 @@ def missedmessage_hook(user_profile_id, queue, last_for_client):
|
|||
if not event['type'] == 'message' or not event['flags']:
|
||||
continue
|
||||
|
||||
if 'mentioned' in event['flags'] and not 'read' in event['flags']:
|
||||
if 'mentioned' in event['flags'] and 'read' not in event['flags']:
|
||||
notify_info = dict(message_id=event['message']['id'])
|
||||
|
||||
if not event.get('push_notified', False):
|
||||
|
@ -603,7 +603,7 @@ def receiver_is_idle(user_profile_id, realm_presences):
|
|||
# presence information in this case (and it's hard to get without an additional
|
||||
# db query) so we simply don't try to guess if this cross-realm recipient
|
||||
# has been idle for too long
|
||||
if realm_presences is None or not user_profile_id in realm_presences:
|
||||
if realm_presences is None or user_profile_id not in realm_presences:
|
||||
return off_zulip
|
||||
|
||||
# We want to find the newest "active" presence entity and compare that to the
|
||||
|
|
|
@ -118,7 +118,7 @@ class SocketConnection(sockjs.tornado.SockJSConnection):
|
|||
if msg['request']['csrf_token'] != self.csrf_token:
|
||||
raise SocketAuthError('CSRF token does not match that in cookie')
|
||||
|
||||
if not 'queue_id' in msg['request']:
|
||||
if 'queue_id' not in msg['request']:
|
||||
raise SocketAuthError("Missing 'queue_id' argument")
|
||||
|
||||
queue_id = msg['request']['queue_id']
|
||||
|
|
|
@ -90,7 +90,7 @@ def users_active_nosend_during_day(day):
|
|||
start__lte=end_day)
|
||||
if len(intervals) != 0:
|
||||
today_users.append(user_profile)
|
||||
return [u for u in today_users if not u.id in today_senders]
|
||||
return [u for u in today_users if u.id not in today_senders]
|
||||
|
||||
def calculate_stats(data, all_users):
|
||||
# type: (List[float], List[UserProfile]) -> Dict[str, Any]
|
||||
|
|
|
@ -653,7 +653,7 @@ class SubscriptionAPITest(AuthedTestCase):
|
|||
all_stream_names = [stream.name for stream in Stream.objects.filter(realm=self.realm)]
|
||||
for stream in existing_stream_names:
|
||||
random_stream = stream + str(random.randint(0, 9))
|
||||
if not random_stream in all_stream_names:
|
||||
if random_stream not in all_stream_names:
|
||||
random_streams.append(random_stream)
|
||||
return random_streams
|
||||
|
||||
|
@ -1100,7 +1100,7 @@ class SubscriptionAPITest(AuthedTestCase):
|
|||
streams_to_remove = self.streams[1:]
|
||||
not_subbed = []
|
||||
for stream in Stream.objects.all():
|
||||
if not stream.name in self.streams:
|
||||
if stream.name not in self.streams:
|
||||
not_subbed.append(stream.name)
|
||||
random.shuffle(not_subbed)
|
||||
self.assertNotEqual(len(not_subbed), 0) # necessary for full test coverage
|
||||
|
|
|
@ -303,7 +303,7 @@ def api_endpoint_docs(request):
|
|||
call["endpoint"] = "%s/v1/%s" % (settings.EXTERNAL_API_URI, call["endpoint"])
|
||||
call["example_request"]["curl"] = call["example_request"]["curl"].replace("https://api.zulip.com", settings.EXTERNAL_API_URI)
|
||||
response = call['example_response']
|
||||
if not '\n' in response:
|
||||
if '\n' not in response:
|
||||
# For 1-line responses, pretty-print them
|
||||
extended_response = response.replace(", ", ",\n ")
|
||||
else:
|
||||
|
@ -897,7 +897,7 @@ def is_buggy_ua(agent):
|
|||
just serve the more conservative CSS to all our desktop apps.
|
||||
"""
|
||||
return ("Humbug Desktop/" in agent or "Zulip Desktop/" in agent or "ZulipDesktop/" in agent) and \
|
||||
not "Mac" in agent
|
||||
"Mac" not in agent
|
||||
|
||||
def get_pointer_backend(request, user_profile):
|
||||
return json_success({'pointer': user_profile.pointer})
|
||||
|
|
|
@ -55,7 +55,7 @@ AVATAR_SALT = get_secret("avatar_salt")
|
|||
# restarted for triggering browser clients to reload.
|
||||
SERVER_GENERATION = int(time.time())
|
||||
|
||||
if not 'DEBUG' in globals():
|
||||
if 'DEBUG' not in globals():
|
||||
# Uncomment end of next line to test JS/CSS minification.
|
||||
DEBUG = DEVELOPMENT # and platform.node() != 'your-machine'
|
||||
|
||||
|
@ -166,7 +166,7 @@ DEFAULT_SETTINGS = {'TWITTER_CONSUMER_KEY': '',
|
|||
}
|
||||
|
||||
for setting_name, setting_val in six.iteritems(DEFAULT_SETTINGS):
|
||||
if not setting_name in vars():
|
||||
if setting_name not in vars():
|
||||
vars()[setting_name] = setting_val
|
||||
|
||||
# These are the settings that we will check that the user has filled in for
|
||||
|
@ -945,7 +945,7 @@ AUTHENTICATION_BACKENDS += ('zproject.backends.ZulipDummyBackend',)
|
|||
POPULATE_PROFILE_VIA_LDAP = bool(AUTH_LDAP_SERVER_URI)
|
||||
|
||||
if POPULATE_PROFILE_VIA_LDAP and \
|
||||
not 'zproject.backends.ZulipLDAPAuthBackend' in AUTHENTICATION_BACKENDS:
|
||||
'zproject.backends.ZulipLDAPAuthBackend' not in AUTHENTICATION_BACKENDS:
|
||||
AUTHENTICATION_BACKENDS += ('zproject.backends.ZulipLDAPUserPopulator',)
|
||||
else:
|
||||
POPULATE_PROFILE_VIA_LDAP = 'zproject.backends.ZulipLDAPAuthBackend' in AUTHENTICATION_BACKENDS or POPULATE_PROFILE_VIA_LDAP
|
||||
|
|
Loading…
Reference in New Issue