Changed `'%s' % value` pattern to `str(value)`.

This commit is contained in:
Nick Pope 2020-05-01 15:54:15 +01:00 committed by Mariusz Felisiak
parent 7668f9bce9
commit 8f10ceaa90
13 changed files with 36 additions and 35 deletions

View File

@ -188,8 +188,9 @@ class Command(BaseCommand):
)
else:
if targets[0][1] is None:
self.stdout.write(self.style.MIGRATE_LABEL(
" Unapply all migrations: ") + "%s" % targets[0][0]
self.stdout.write(
self.style.MIGRATE_LABEL(' Unapply all migrations: ') +
str(targets[0][0])
)
else:
self.stdout.write(self.style.MIGRATE_LABEL(

View File

@ -351,7 +351,7 @@ class ConsoleDirective(CodeBlock):
if env.app.builder.name not in ('djangohtml', 'json'):
return [lit_blk_obj]
lit_blk_obj['uid'] = '%s' % env.new_serialno('console')
lit_blk_obj['uid'] = str(env.new_serialno('console'))
# Only add the tabbed UI if there is actually a Windows-specific
# version of the CLI example.
win_content = code_block_to_win(self.content)

View File

@ -3055,14 +3055,14 @@ class AdminViewListEditable(TestCase):
"form-MAX_NUM_FORMS": "0",
"form-0-gender": "1",
"form-0-id": "%s" % self.per1.pk,
"form-0-id": str(self.per1.pk),
"form-1-gender": "2",
"form-1-id": "%s" % self.per2.pk,
"form-1-id": str(self.per2.pk),
"form-2-alive": "checked",
"form-2-gender": "1",
"form-2-id": "%s" % self.per3.pk,
"form-2-id": str(self.per3.pk),
"_save": "Save",
}
@ -3077,14 +3077,14 @@ class AdminViewListEditable(TestCase):
"form-MAX_NUM_FORMS": "0",
"form-0-gender": "1",
"form-0-id": "%s" % self.per1.pk,
"form-0-id": str(self.per1.pk),
"form-1-gender": "2",
"form-1-id": "%s" % self.per2.pk,
"form-1-id": str(self.per2.pk),
"form-2-alive": "checked",
"form-2-gender": "1",
"form-2-id": "%s" % self.per3.pk,
"form-2-id": str(self.per3.pk),
"_save": "Save",
}
@ -3099,11 +3099,11 @@ class AdminViewListEditable(TestCase):
"form-INITIAL_FORMS": "2",
"form-MAX_NUM_FORMS": "0",
"form-0-id": "%s" % self.per1.pk,
"form-0-id": str(self.per1.pk),
"form-0-gender": "1",
"form-0-alive": "checked",
"form-1-id": "%s" % self.per3.pk,
"form-1-id": str(self.per3.pk),
"form-1-gender": "1",
"form-1-alive": "checked",
@ -3119,7 +3119,7 @@ class AdminViewListEditable(TestCase):
"form-INITIAL_FORMS": "1",
"form-MAX_NUM_FORMS": "0",
"form-0-id": "%s" % self.per1.pk,
"form-0-id": str(self.per1.pk),
"form-0-gender": "1",
"_save": "Save",
@ -3209,7 +3209,7 @@ class AdminViewListEditable(TestCase):
"form-INITIAL_FORMS": "1",
"form-MAX_NUM_FORMS": "0",
"form-0-id": "%s" % self.per2.pk,
"form-0-id": str(self.per2.pk),
"form-0-alive": "1",
"form-0-gender": "2",
@ -3227,7 +3227,7 @@ class AdminViewListEditable(TestCase):
"form-INITIAL_FORMS": "1",
"form-MAX_NUM_FORMS": "0",
"form-0-id": "%s" % self.per2.pk,
"form-0-id": str(self.per2.pk),
"form-0-alive": "1",
"form-0-gender": "2",
@ -3334,14 +3334,14 @@ class AdminViewListEditable(TestCase):
"form-MAX_NUM_FORMS": "0",
"form-0-gender": "1",
"form-0-id": "%s" % self.per1.pk,
"form-0-id": str(self.per1.pk),
"form-1-gender": "2",
"form-1-id": "%s" % self.per2.pk,
"form-1-id": str(self.per2.pk),
"form-2-alive": "checked",
"form-2-gender": "1",
"form-2-id": "%s" % self.per3.pk,
"form-2-id": str(self.per3.pk),
"_save": "Save",
"_selected_action": ['1'],

View File

@ -4,9 +4,9 @@ from django.http import HttpResponse
@staff_member_required
def secure_view(request):
return HttpResponse('%s' % request.POST)
return HttpResponse(str(request.POST))
@staff_member_required(redirect_field_name='myfield')
def secure_view2(request):
return HttpResponse('%s' % request.POST)
return HttpResponse(str(request.POST))

View File

@ -237,7 +237,7 @@ class AdminForeignKeyRawIdWidget(TestDataMixin, TestCase):
pk = band.pk
band.delete()
post_data = {
"main_band": '%s' % pk,
"main_band": str(pk),
}
# Try posting with a nonexistent pk in a raw id field: this
# should result in an error message, not a server exception.

View File

@ -81,7 +81,7 @@ class Time(models.Model):
time = models.TimeField(null=True)
def __str__(self):
return "%s" % self.time
return str(self.time)
class SimulationRun(models.Model):

View File

@ -77,9 +77,9 @@ class GenericAdminViewTest(TestDataMixin, TestCase):
"generic_inline_admin-media-content_type-object_id-TOTAL_FORMS": "3",
"generic_inline_admin-media-content_type-object_id-INITIAL_FORMS": "2",
"generic_inline_admin-media-content_type-object_id-MAX_NUM_FORMS": "0",
"generic_inline_admin-media-content_type-object_id-0-id": "%d" % self.mp3_media_pk,
"generic_inline_admin-media-content_type-object_id-0-id": str(self.mp3_media_pk),
"generic_inline_admin-media-content_type-object_id-0-url": "http://example.com/podcast.mp3",
"generic_inline_admin-media-content_type-object_id-1-id": "%d" % self.png_media_pk,
"generic_inline_admin-media-content_type-object_id-1-id": str(self.png_media_pk),
"generic_inline_admin-media-content_type-object_id-1-url": "http://example.com/logo.png",
"generic_inline_admin-media-content_type-object_id-2-id": "",
"generic_inline_admin-media-content_type-object_id-2-url": "",
@ -250,7 +250,7 @@ class GenericInlineAdminWithUniqueTogetherTest(TestDataMixin, TestCase):
"generic_inline_admin-phonenumber-content_type-object_id-MAX_NUM_FORMS": "0",
"generic_inline_admin-phonenumber-content_type-object_id-0-id": "",
"generic_inline_admin-phonenumber-content_type-object_id-0-phone_number": "555-555-5555",
"generic_inline_admin-phonenumber-content_type-object_id-0-category": "%s" % category_id,
"generic_inline_admin-phonenumber-content_type-object_id-0-category": str(category_id),
}
response = self.client.get(reverse('admin:generic_inline_admin_contact_add'))
self.assertEqual(response.status_code, 200)

View File

@ -40,7 +40,7 @@ class Car(models.Model):
drivers = models.ManyToManyField('Driver', through='CarDriver')
def __str__(self):
return "%s" % self.make
return str(self.make)
class Driver(models.Model):
@ -50,7 +50,7 @@ class Driver(models.Model):
ordering = ('name',)
def __str__(self):
return "%s" % self.name
return str(self.name)
class CarDriver(models.Model):

View File

@ -1756,7 +1756,7 @@ class TestModelFormsetOverridesTroughFormMeta(TestCase):
PoetFormSet = modelformset_factory(Poet, fields="__all__", widgets=widgets)
form = PoetFormSet.form()
self.assertHTMLEqual(
"%s" % form['name'],
str(form['name']),
'<input id="id_name" maxlength="100" type="text" class="poet" name="name" required>'
)
@ -1767,7 +1767,7 @@ class TestModelFormsetOverridesTroughFormMeta(TestCase):
BookFormSet = inlineformset_factory(Author, Book, widgets=widgets, fields="__all__")
form = BookFormSet.form()
self.assertHTMLEqual(
"%s" % form['title'],
str(form['title']),
'<input class="book" id="id_title" maxlength="100" name="title" type="text" required>'
)

View File

@ -386,7 +386,7 @@ class Node(models.Model):
parent = models.ForeignKey("self", models.SET_NULL, to_field="num", null=True)
def __str__(self):
return "%s" % self.num
return str(self.num)
# Bug #12252
@ -604,7 +604,7 @@ class Order(models.Model):
ordering = ('pk',)
def __str__(self):
return '%s' % self.pk
return str(self.pk)
class OrderItem(models.Model):
@ -615,7 +615,7 @@ class OrderItem(models.Model):
ordering = ('pk',)
def __str__(self):
return '%s' % self.pk
return str(self.pk)
class BaseUser(models.Model):

View File

@ -145,7 +145,7 @@ class HttpResponseTests(SimpleTestCase):
self.assertEqual(r.content, content.encode(UTF8))
def test_generator_cache(self):
generator = ("{}".format(i) for i in range(10))
generator = (str(i) for i in range(10))
response = HttpResponse(content=generator)
self.assertEqual(response.content, b'0123456789')
with self.assertRaises(StopIteration):

View File

@ -108,7 +108,7 @@ class Team:
raise NotImplementedError("Not so simple")
def to_string(self):
return "%s" % self.title
return str(self.title)
class TeamField(models.CharField):

View File

@ -170,12 +170,12 @@ def escape_format_html(context):
@register.simple_tag(takes_context=True)
def current_app(context):
return "%s" % context.current_app
return str(context.current_app)
@register.simple_tag(takes_context=True)
def use_l10n(context):
return "%s" % context.use_l10n
return str(context.use_l10n)
@register.simple_tag(name='minustwo')