From 6fa4e4e1b0bbe90ce09168bca4ede6d4450d27c5 Mon Sep 17 00:00:00 2001 From: shankar ambady Date: Fri, 17 Jan 2025 15:10:50 -0500 Subject: [PATCH] fixing format specifiers --- channels/serializers_test.py | 2 +- learning_resources/factories.py | 18 +++++++++--------- learning_resources/filters.py | 2 +- news_events/factories.py | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/channels/serializers_test.py b/channels/serializers_test.py index ab7da1b83f..fd3068f2bd 100644 --- a/channels/serializers_test.py +++ b/channels/serializers_test.py @@ -155,7 +155,7 @@ def test_create_channel(base_channel_data, channel_detail, channel_type): """ paths = sorted( (p.learning_resource for p in LearningPathFactory.create_batch(2)), - key=lambda list: list.id, + key=lambda lst: lst.id, reverse=True, ) diff --git a/learning_resources/factories.py b/learning_resources/factories.py index 1451ffb93a..9aaed9a1be 100644 --- a/learning_resources/factories.py +++ b/learning_resources/factories.py @@ -64,7 +64,7 @@ def _post_gen_tags(obj, create, extracted, **kwargs): # noqa: ARG001 class LearningResourceContentTagFactory(DjangoModelFactory): """Factory for LearningResourceContentTag objects""" - name = factory.Sequence(lambda n: "Tag %03d" % n) + name = factory.Sequence(lambda n: f"Tag {n:03d}") class Meta: model = models.LearningResourceContentTag @@ -86,7 +86,7 @@ class Meta: class LearningResourceTopicFactory(DjangoModelFactory): """Factory for learning resource topics""" - name = factory.Sequence(lambda n: "Topic %03d" % n) + name = factory.Sequence(lambda n: f"Topic {n:03d}") class Meta: model = models.LearningResourceTopic @@ -137,7 +137,7 @@ class Meta: class LearningResourceSchoolFactory(DjangoModelFactory): """Factory for LearningResourceDepartment""" - name = factory.Sequence(lambda n: "%03d name" % n) + name = factory.Sequence(lambda n: f"{n:03d} name") url = factory.Faker("url") class Meta: @@ -147,8 +147,8 @@ class Meta: class LearningResourceDepartmentFactory(DjangoModelFactory): """Factory for LearningResourceDepartment""" - department_id = factory.Sequence(lambda n: "%03d" % n) - name = factory.Sequence(lambda n: "%03d name" % n) + department_id = factory.Sequence(lambda n: f"{n:03d}") + name = factory.Sequence(lambda n: f"{n:03d} name") school = factory.SubFactory( "learning_resources.factories.LearningResourceSchoolFactory" ) @@ -198,7 +198,7 @@ class LearningResourceFactory(DjangoModelFactory): choices=constants.LearningResourceType.names() ) readable_id = factory.Sequence( - lambda n: "RESOURCEN%03d_%03d.MIT" % (n, random.randint(1, 1000)) # noqa: S311 + lambda n: f"RESOURCEN{n:03d}_{random.randint(1, 1000)}.MIT" # noqa: S311 ) etl_source = "mock" title = factory.Faker("word") @@ -493,7 +493,7 @@ class LearningResourceRunFactory(DjangoModelFactory): ] ), ) - run_id = factory.Sequence(lambda n: "RUN%03d.MIT_run" % n) + run_id = factory.Sequence(lambda n: f"RUN{n:03d}.MIT_run") title = factory.Faker("word") description = factory.Faker("sentence") full_description = factory.Faker("text") @@ -839,7 +839,7 @@ class VideoFactory(DjangoModelFactory): is_video=True, create_video=False, ) - duration = factory.Sequence(lambda n: "PT%02dM%02dS" % (n, n)) + duration = factory.Sequence(lambda n: f"PT{n:02d}M{n:02d}S") class Meta: model = models.Video @@ -852,7 +852,7 @@ class Params: class VideoChannelFactory(DjangoModelFactory): """Factory for VideoChannels""" - channel_id = factory.Sequence(lambda n: "VIDEO-CHANNEL-%03d.MIT" % n) + channel_id = factory.Sequence(lambda n: f"VIDEO-CHANNEL-{n:03d}.MIT") title = factory.Faker("word") class Params: diff --git a/learning_resources/filters.py b/learning_resources/filters.py index bd23cd4929..38b65be0d5 100644 --- a/learning_resources/filters.py +++ b/learning_resources/filters.py @@ -132,7 +132,7 @@ def filter_free(self, queryset, _, value): free_filter = ( Q(runs__isnull=True) | Q(runs__resource_prices__isnull=True) - | Q(runs__resource_prices__amount=Decimal(0.00)) + | Q(runs__resource_prices__amount=Decimal("0.00")) ) & Q(professional=False) if value: # Free resources diff --git a/news_events/factories.py b/news_events/factories.py index 6b70e39051..688a434c98 100644 --- a/news_events/factories.py +++ b/news_events/factories.py @@ -53,7 +53,7 @@ class FeedItemFactory(factory.django.DjangoModelFactory): """Factory for feed items""" source = factory.SubFactory(FeedSourceFactory) - guid = factory.Sequence(lambda n: "http://feed.mit.edu/%03d/rss" % n) + guid = factory.Sequence(lambda n: f"http://feed.mit.edu/{n:03d}/rss") title = factory.Faker("word") url = factory.Faker("url") summary = factory.Faker("paragraph")