pep8: Fix E303 violations.

This commit is contained in:
Sidhant Bhavnani 2016-12-02 16:18:11 +00:00 committed by Tim Abbott
parent 9f0383520c
commit 8c0c12c1d9
42 changed files with 1 additions and 68 deletions

View File

@ -57,7 +57,6 @@ Usage examples:
print("%25s %15d" % (count[1], count[0]))
print("Total:", total)
def handle(self, *args, **options):
# type: (*Any, **str) -> None
if options['arg'] is None:

View File

@ -89,7 +89,6 @@ def get_realm_day_counts():
for row in rows:
counts[row['domain']][row['age']] = row['cnt']
result = {}
for domain in counts:
raw_cnts = [counts[domain].get(age, 0) for age in range(8)]
@ -260,7 +259,6 @@ def realm_summary_table(realm_minutes):
total_bot_count += int(row['bot_count'])
total_at_risk_count += int(row['at_risk_count'])
rows.append(dict(
domain='Total',
active_user_count=total_active_user_count,
@ -695,7 +693,6 @@ def get_user_activity_summary(records):
update('pointer', record)
update(client, record)
return summary
def format_date_for_activity_reports(date):
@ -887,7 +884,6 @@ def get_realm_activity(request, realm):
content = realm_client_table(all_user_records)
data += [(page_title, content)]
page_title = 'History'
content = sent_messages_report(realm)
data += [(page_title, content)]

View File

@ -89,7 +89,6 @@ def main(argv=None):
help='Allows the user to specify a subject for the message.')
parser.add_option_group(group)
(options, recipients) = parser.parse_args(argv[1:])
if options.verbose:

View File

@ -21,7 +21,6 @@
# THE SOFTWARE.
# Change these values to configure authentication for basecamp account
BASECAMP_ACCOUNT_ID = "12345678"
BASECAMP_USERNAME = "foo@example.com"

View File

@ -21,7 +21,6 @@
# THE SOFTWARE.
# Change these values to configure authentication for your codebase account
# Note that this is the Codebase API Username, found in the Settings page
# for your account

View File

@ -116,7 +116,6 @@ def handle_event(event):
url = make_url("projects/%s" % (project_link,))
scm = "of type %s" % (project_repo_type,) if project_repo_type else ""
subject = "Repository %s Created" % (project_name,)
content = "%s created a new repository %s [%s](%s)" % (actor_name, scm, project_name, url)
elif event_type == 'push':
@ -165,7 +164,6 @@ def handle_event(event):
body = raw_props.get('content')
changes = raw_props.get('changes')
url = make_url("projects/%s/tickets/%s" % (project_link, num))
subject = "#%s: %s" % (num, name)

View File

@ -873,7 +873,6 @@ class P4UserMap(object):
self.users[output["User"]] = output["FullName"] + " <" + output["Email"] + ">"
self.emails[output["Email"]] = output["User"]
s = ''
for (key, val) in self.users.items():
s += "%s\t%s\n" % (key.expandtabs(1), val.expandtabs(1))
@ -959,7 +958,6 @@ class P4RollBack(Command):
log = extractLogMessageFromGitCommit(ref)
settings = extractSettingsGitLog(log)
depotPaths = settings['depot-paths']
change = settings['change']
@ -2480,7 +2478,6 @@ class P4Sync(Command, P4UserMap):
if source not in self.knownBranches:
lostAndFoundBranches.add(source)
for branch in lostAndFoundBranches:
self.knownBranches[branch] = branch
@ -2698,7 +2695,6 @@ class P4Sync(Command, P4UserMap):
sys.stderr.write("p4 exitcode: %s\n" % info['p4ExitCode'])
sys.exit(1)
change = int(info["change"])
if change > newestRevision:
newestRevision = change
@ -2727,7 +2723,6 @@ class P4Sync(Command, P4UserMap):
print("IO error with git fast-import. Is your git version recent enough?")
print(self.gitError.read())
def run(self, args):
self.depotPaths = []
self.changeRange = ""

View File

@ -114,7 +114,6 @@ for device in macs.values():
['/sbin/iptables', '-t', 'mangle', '-A', 'OUTPUT', '-m', 'conntrack', '--ctorigdst',
address_of(device_number), '-j', 'MARK', '--set-mark', str(device_number)])
to_configure.remove(address_of(device_number))
for (count, ip) in enumerate(to_configure):

View File

@ -91,7 +91,6 @@ def create_user_docs():
# type: () -> None
fn = 'var/url_coverage.txt' # TODO: make path more robust, maybe use json suffix
out_dir = 'var/api_docs'
try:
os.mkdir(out_dir)

View File

@ -84,7 +84,7 @@ def check_pep8(files):
failed = False
ignored_rules = [
'E402', 'E501', 'W503', 'E711', 'E128', 'E226',
'E126', 'E121', 'E123', 'E266', 'E265', 'E261', 'E221', 'E303',
'E126', 'E121', 'E123', 'E266', 'E265', 'E261', 'E221',
'E241', 'E712', 'E702', 'E401', 'E115', 'E114', 'E731', 'E302', 'E129',
'E741', 'E714', 'W391', 'E713', 'E502', 'E305', 'E251', 'E306',
]
@ -451,7 +451,6 @@ def run():
print('If you really know what you are doing, use --force to run anyway.')
sys.exit(1)
by_lang = cast(Dict[str, List[str]], lister.list_files(args, modified_only=options.modified,
ftypes=['py', 'sh', 'js', 'pp', 'css', 'handlebars', 'html', 'json', 'md', 'txt', 'text'],
use_shebang=True, group_by_ftype=True, exclude=EXCLUDED_FILES))

View File

@ -186,7 +186,6 @@ class ParserTest(unittest.TestCase):
'''
validate(text=my_html)
def test_tokenize(self):
# type: () -> None
tag = '<meta whatever>bla'

View File

@ -1479,7 +1479,6 @@ def notify_subscriptions_added(user_profile, sub_pairs, stream_emails, no_log=Fa
def get_peer_user_ids_for_stream_change(stream, altered_users, subscribed_users):
# type: (Stream, Iterable[UserProfile], Iterable[UserProfile]) -> Set[int]
'''
altered_users is a list of users that we are adding/removing
subscribed_users is the list of already subscribed users
@ -1620,7 +1619,6 @@ def bulk_add_subscriptions(streams, users):
user_id=added_user.id)
send_event(event, peer_user_ids)
return ([(user_profile, stream) for (user_profile, recipient_id, stream) in new_subs] +
[(sub.user_profile, stream) for (sub, stream) in subs_to_activate],
already_subscribed)
@ -2660,7 +2658,6 @@ def do_update_message(user_profile, message, subject, propagate_mode, content, r
event['subject_links'] = bugdown.subject_links(message.sender.realm.domain.lower(), subject)
edit_history_event["prev_subject"] = orig_subject
if propagate_mode in ["change_later", "change_all"]:
propagate_query = Q(recipient = message.recipient, subject = orig_subject)
# We only change messages up to 2 days in the past, to avoid hammering our

View File

@ -98,7 +98,6 @@ class FencedCodeExtension(markdown.Extension):
""" Add FencedBlockPreprocessor to the Markdown instance. """
md.registerExtension(self)
# Newer versions of Python-Markdown (starting at 2.3?) have
# a normalize_whitespace preprocessor that needs to go first.
position = ('>normalize_whitespace'

View File

@ -208,7 +208,6 @@ class Config(object):
parent_key=None, use_all=False, is_seeded=False, exclude=None):
# type: (str, Any, Config, Config, FilterArgs, CustomFetch, List[TableName], PostProcessData, List[TableName], IdSource, SourceFilter, Field, bool, bool, List[Field]) -> None
assert table or custom_tables
self.table = table
self.model = model
@ -273,7 +272,6 @@ def export_from_config(response, config, seed_object=None, context=None):
if context is None:
context = {}
if table:
exported_tables = [table]
else:
@ -493,7 +491,6 @@ def get_realm_config():
post_process_data=sanity_check_stream_data
)
#
Config(

View File

@ -222,7 +222,6 @@ class MessageDict(object):
def re_render_content_for_management_command(message):
# type: (Message) -> None
'''
Please avoid using this function, as its only used in a management command that
is somewhat deprecated.

View File

@ -131,7 +131,6 @@ def mkdir_p(path):
def query_chunker(queries, id_collector=None, chunk_size=1000, db_chunk_size=None):
# type: (List[Any], Set[int], int, int) -> Iterable[Any]
'''
This merges one or more Django ascending-id queries into
a generator that returns chunks of chunk_size row objects

View File

@ -24,7 +24,6 @@ class Command(BaseCommand):
default=False,
help="Only logout all users who are deactivated")
def handle(self, *args, **options):
# type: (*Any, **Any) -> None
if options["realm"]:

View File

@ -181,7 +181,6 @@ class Command(makemessages.Command):
# type: () -> str
return self.frontend_source
def get_namespace(self):
# type: () -> str
return self.frontend_namespace

View File

@ -1280,7 +1280,6 @@ class UserPresence(models.Model):
user__is_bot=False,
).distinct("user").values("user")]
for row in query:
info = UserPresence.to_presence_dict(
client_name=row['client__name'],

View File

@ -45,7 +45,6 @@ class AlertWordTests(ZulipTestCase):
words = user_alert_words(user)
self.assertEqual(words, ['milk', 'cookies'])
def test_default_no_words(self):
# type: () -> None
"""
@ -132,7 +131,6 @@ class AlertWordTests(ZulipTestCase):
result = self.client_put('/json/users/me/alert_words', {'alert_words': ujson.dumps(['one', 'two', 'three'])})
self.assert_json_success(result)
result = self.client_get('/json/users/me/alert_words')
self.assert_json_success(result)
data = ujson.loads(result.content)

View File

@ -156,7 +156,6 @@ class AuthBackendTest(TestCase):
bad_kwargs=dict(password="wrong"),
good_kwargs=dict(password=password))
def test_email_auth_backend_disabled_password_auth(self):
# type: () -> None
email = u"hamlet@zulip.com"
@ -287,7 +286,6 @@ class AuthBackendTest(TestCase):
email_to_username=email_to_username,
good_kwargs=dict(realm_subdomain='acme'))
with self.settings(REALMS_HAVE_SUBDOMAINS=True):
# With subdomains, authenticating with the right subdomain
# works; using the wrong subdomain doesn't

View File

@ -201,7 +201,6 @@ class BugdownTest(TestCase):
href = 'http://' + url
return payload % ("<a href=\"%s\"%s title=\"%s\">%s</a>" % (href, target, href, url),)
print("Running Bugdown Linkify tests")
self.maxDiff = None # type: Optional[int]
for inline_url, reference, url in linkify_tests:
@ -448,7 +447,6 @@ class BugdownTest(TestCase):
'<RealmFilter(zulip.com): #(?P<id>[0-9]{2,8})'
' https://trac.zulip.net/ticket/%(id)s>')
msg = Message(sender=get_user_profile_by_email("othello@zulip.com"),
subject="#444")

View File

@ -63,7 +63,6 @@ class DecoratorTestCase(TestCase):
self.assertEqual(get_client_name(req, is_json_view=True), 'website')
self.assertEqual(get_client_name(req, is_json_view=False), 'Mozilla')
req = Request(
GET=dict(),
POST=dict(),
@ -82,7 +81,6 @@ class DecoratorTestCase(TestCase):
self.assertEqual(get_client_name(req, is_json_view=True), 'fancy phone')
self.assertEqual(get_client_name(req, is_json_view=False), 'fancy phone')
def test_REQ_converter(self):
def my_converter(data):

View File

@ -672,7 +672,6 @@ class EventsRegisterTest(ZulipTestCase):
error = schema_checker('events[0]', events[0])
self.assert_on_error(error)
def test_create_bot(self):
# type: () -> None
bot_created_checker = check_dict([

View File

@ -267,7 +267,6 @@ class ExportTest(TestCase):
r for r in data[table]
if r['id'] == db_id][0]
exported_user_emails = get_set('zerver_userprofile', 'email')
self.assertIn('cordelia@zulip.com', exported_user_emails)
self.assertIn('default-bot@zulip.com', exported_user_emails)
@ -288,7 +287,6 @@ class ExportTest(TestCase):
exported_message = find_by_id('zerver_message', um.message_id)
self.assertEqual(exported_message['content'], um.message.content)
# TODO, extract get_set/find_by_id, so we can split this test up
# Now, restrict users

View File

@ -63,7 +63,6 @@ class RateLimitTests(ZulipTestCase):
settings.RATE_LIMITING = True
add_ratelimit_rule(1, 5)
def tearDown(self):
# type: () -> None
settings.RATE_LIMITING = False

View File

@ -161,7 +161,6 @@ class TestCrossRealmPMs(ZulipTestCase):
dep.realms = [get_realm_by_string_id("zulip")]
dep.save()
def create_user(self, email):
# type: (text_type) -> UserProfile
username, domain = email.split('@')

View File

@ -480,7 +480,6 @@ class GetOldMessagesTest(ZulipTestCase):
stream_id = stream_messages[i].recipient.id
self.assertEqual(message["recipient_id"], stream_id)
def test_get_old_messages_with_narrow_sender(self):
"""
A request for old messages with a narrow by sender only returns
@ -550,7 +549,6 @@ class GetOldMessagesTest(ZulipTestCase):
self.assertEqual(message['match_content'],
u'<p><span class="highlight">KEYWORDMATCH</span> and should work</p>')
@override_settings(USING_PGROONGA=False)
def test_get_old_messages_with_search(self):
self.login("cordelia@zulip.com")

View File

@ -133,7 +133,6 @@ class UserPresenceTests(ZulipTestCase):
json = post_presence()
self.assertEqual(json['zephyr_mirror_active'], True)
def _simulate_mirror_activity_for_user(self, user_profile):
# type: (UserProfile) -> None
last_visit = timezone.now()
@ -147,7 +146,6 @@ class UserPresenceTests(ZulipTestCase):
last_visit=last_visit
)
def test_same_realm(self):
# type: () -> None
self.login("espuser@mit.edu")

View File

@ -143,7 +143,6 @@ class TestPushApi(ZulipTestCase):
result = self.client_delete(endpoint, {'token': 'non-existent token'})
self.assert_json_error(result, 'Token does not exist')
# Add tokens
for endpoint, token in endpoints:
# Test that we can push twice

View File

@ -1025,7 +1025,6 @@ class UserSignUpTest(ZulipTestCase):
"newuser@zulip.com"],
result)
mock_ldap.reset()
mock_initialize.stop()

View File

@ -743,7 +743,6 @@ class SubscriptionPropertiesTest(ZulipTestCase):
self.assert_json_error(
result, "Not subscribed to stream %s" % (unsubs_stream,))
def test_json_subscription_property_invalid_verb(self):
# type: () -> None
"""
@ -1452,7 +1451,6 @@ class SubscriptionAPITest(ZulipTestCase):
self.assertEqual(add_peer_event['event']['op'], 'peer_add')
self.assertEqual(add_peer_event['event']['user_id'], user_profile.id)
def test_users_getting_add_peer_event(self):
# type: () -> None
"""

View File

@ -207,7 +207,6 @@ class StoppedTypingNotificationTest(ZulipTestCase):
self.assertEqual(event['type'], 'typing')
self.assertEqual(event['op'], 'stop')
def test_send_notification_to_another_user_event(self):
# type: () -> None
"""

View File

@ -192,7 +192,6 @@ class UnreadCountTests(ZulipTestCase):
if msg.user_profile.email == "hamlet@zulip.com":
self.assertFalse(msg.flags.read)
def test_mark_all_in_invalid_stream_read(self):
# type: () -> None
self.login("hamlet@zulip.com")
@ -242,7 +241,6 @@ class UnreadCountTests(ZulipTestCase):
if msg.user_profile.email == "hamlet@zulip.com":
self.assertFalse(msg.flags.read)
def test_mark_all_in_invalid_topic_read(self):
# type: () -> None
self.login("hamlet@zulip.com")

View File

@ -432,7 +432,6 @@ class ZephyrTest(ZulipTestCase):
'MTIzNA=='])
class AdminCreateUserTest(ZulipTestCase):
def test_create_user_backend(self):
# type: () -> None
@ -529,7 +528,6 @@ class WorkerTest(TestCase):
callback = self.consumers[queue_name]
callback(data)
def test_UserActivityWorker(self):
# type: () -> None
fake_client = self.FakeClient()
@ -1570,7 +1568,6 @@ class ChangeSettingsTest(ZulipTestCase):
dict(full_name='x' * 1000))
self.assert_json_error(json_result, 'Name too long!')
# This is basically a don't-explode test.
def test_notify_settings(self):
# type: () -> None
@ -1941,7 +1938,6 @@ class HomeTest(ZulipTestCase):
html = result.content.decode('utf-8')
self.assertIn('There is a new terms of service', html)
def test_bad_narrow(self):
# type: () -> None
email = 'hamlet@zulip.com'

View File

@ -62,7 +62,6 @@ class DeskDotComHookTests(WebhookTestCase):
content_type="application/x-www-form-urlencoded",
**self.api_auth(self.TEST_USER_EMAIL))
def get_body(self, fixture_name):
# type: (text_type) -> text_type
return self.fixture_data("deskdotcom", fixture_name, file_type="txt")

View File

@ -221,7 +221,6 @@ class GithubV2HookTests(WebhookTestCase):
)
self.basic_test('push_commits_more_than_limit', 'commits', 'zulip-test / master', expected_subject)
def test_legacy_hook(self):
# type: () -> None
self.basic_test('push', 'commits', 'zulip-test / master', self.push_content)

View File

@ -222,7 +222,6 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):
response = middleware_method(request, response)
response = response.render()
except http.Http404 as e:
if settings.DEBUG:
from django.views import debug

View File

@ -457,7 +457,6 @@ def get_streams_backend(request, user_profile,
include_default=REQ(validator=check_bool, default=False)):
# type: (HttpRequest, UserProfile, bool, bool, bool, bool) -> HttpResponse
streams = do_get_streams(user_profile, include_public=include_public,
include_subscribed=include_subscribed,
include_all_active=include_all_active,

View File

@ -242,7 +242,6 @@ def add_bot_backend(request, user_profile, full_name=REQ(), short_name=REQ(),
subscribed_to_stream(user_profile, default_events_register_stream):
return json_error(_('Insufficient permission'))
bot_profile = do_create_user(email=email, password='',
realm=user_profile.realm, full_name=full_name,
short_name=short_name, active=True,

View File

@ -8,7 +8,6 @@ from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_vi
from zerver.models import UserProfile, Client
@api_key_only_webhook_view('IFTTT')
@has_request_variables
def api_iftt_app_webhook(request, user_profile, client,

View File

@ -196,7 +196,6 @@ def parse_change_event(change_type, message):
event_type = "changed_" + change_type
values.update({'old': old, 'new': new})
elif change_type == "is_blocked":
if message["change"]["diff"]["is_blocked"]["to"]:
event_type = "blocked"
@ -219,7 +218,6 @@ def parse_change_event(change_type, message):
old, new = get_old_and_new_values(change_type, message)
values.update({'old': old, 'new': new})
elif change_type in ["estimated_finish", "estimated_start"]:
old, new = get_old_and_new_values(change_type, message)
if not old == new: