python: Modernize legacy Python 2 syntax with pyupgrade.

Generated by `pyupgrade --py3-plus --keep-percent-format` on all our
Python code except `zthumbor` and `zulip-ec2-configure-interfaces`,
followed by manual indentation fixes.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg
2020-04-09 12:51:58 -07:00
committed by Tim Abbott
parent fff2d3958a
commit c734bbd95d
567 changed files with 1877 additions and 2564 deletions

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
from django.conf import settings
from django.contrib.auth import authenticate
@@ -3922,7 +3921,7 @@ class TestMaybeSendToRegistration(ZulipTestCase):
result = self.client_get(result.url)
self.assert_in_response('action="/accounts/register/"', result)
self.assert_in_response('value="{0}" name="key"'.format(confirmation_key), result)
self.assert_in_response('value="{}" name="key"'.format(confirmation_key), result)
def test_sso_only_when_preregistration_user_exists(self) -> None:
rf = RequestFactory()
@@ -3957,7 +3956,7 @@ class TestAdminSetBackends(ZulipTestCase):
# Log in as admin
self.login('iago')
result = self.client_patch("/json/realm", {
'authentication_methods': ujson.dumps({u'Email': False, u'Dev': True})})
'authentication_methods': ujson.dumps({'Email': False, 'Dev': True})})
self.assert_json_success(result)
realm = get_realm('zulip')
self.assertFalse(password_auth_enabled(realm))
@@ -3967,7 +3966,7 @@ class TestAdminSetBackends(ZulipTestCase):
# Log in as admin
self.login('iago')
result = self.client_patch("/json/realm", {
'authentication_methods': ujson.dumps({u'Email': False, u'Dev': False})})
'authentication_methods': ujson.dumps({'Email': False, 'Dev': False})})
self.assert_json_error(result, 'At least one authentication method must be enabled.')
realm = get_realm('zulip')
self.assertTrue(password_auth_enabled(realm))
@@ -3978,7 +3977,7 @@ class TestAdminSetBackends(ZulipTestCase):
self.login('iago')
# Set some supported and unsupported backends
result = self.client_patch("/json/realm", {
'authentication_methods': ujson.dumps({u'Email': False, u'Dev': True, u'GitHub': False})})
'authentication_methods': ujson.dumps({'Email': False, 'Dev': True, 'GitHub': False})})
self.assert_json_success(result)
realm = get_realm('zulip')
# Check that unsupported backend is not enabled
@@ -3992,7 +3991,7 @@ class EmailValidatorTestCase(ZulipTestCase):
def test_invalid_email(self) -> None:
with self.assertRaises(JsonableError):
validate_login_email(u'hamlet')
validate_login_email('hamlet')
def test_validate_email(self) -> None:
inviter = self.example_user('hamlet')