diff --git a/authentication/middleware.py b/authentication/middleware.py
index b52eeccb5b..f0d517f329 100644
--- a/authentication/middleware.py
+++ b/authentication/middleware.py
@@ -30,7 +30,7 @@ def process_exception(self, request, exception):
url = self.get_redirect_uri(request, exception)
if url: # noqa: RET503
- url += ("?" in url and "&" or "?") + "message={}&backend={}".format( # noqa: UP030, UP032
+ url += ("?" in url and "&" or "?") + "message={}&backend={}".format( # noqa: UP032
quote(message), backend_name
)
return redirect(url)
diff --git a/authentication/pipeline/user.py b/authentication/pipeline/user.py
index 5c21c60ff6..60041ee759 100644
--- a/authentication/pipeline/user.py
+++ b/authentication/pipeline/user.py
@@ -145,7 +145,7 @@ def create_user_via_email(
created_user = create_user_with_generated_username(serializer, username)
if created_user is None:
raise IntegrityError( # noqa: TRY301
- f"Failed to create User with generated username ({username})" # noqa: EM103, UP032
+ f"Failed to create User with generated username ({username})"
)
except Exception as exc:
raise UserCreationFailedException(backend, current_partial) from exc
diff --git a/cms/models.py b/cms/models.py
index 29471a899c..93a8bc02e6 100644
--- a/cms/models.py
+++ b/cms/models.py
@@ -213,7 +213,7 @@ def get_context(self, request, *args, **kwargs):
.exclude(Q(category=UPCOMING_WEBINAR) & Q(date__lt=now_in_utc().date()))
.order_by("-category", "date")
)
- webinars_dict = defaultdict(list) # noqa: PIE807
+ webinars_dict = defaultdict(list)
for webinar in webinars:
webinar.detail_page_url = webinar.detail_page_url(request)
webinars_dict[webinar.category].append(webinar)
@@ -1026,7 +1026,7 @@ def get_url_parts(self, request=None):
# of the Course/Program instead (e.g.: "/courses/course-v1:edX+DemoX+Demo_Course")
re.sub(
self.slugged_page_path_pattern,
- fr"\1{self.product.readable_id}\3", # noqa: UP032
+ rf"\1{self.product.readable_id}\3",
url_parts[2],
),
)
@@ -1505,7 +1505,7 @@ class Meta:
def can_create_at(cls, parent):
# You can only create one of these page under course / program.
return (
- super().can_create_at(parent) # noqa: UP008
+ super().can_create_at(parent)
and parent.get_children().type(cls).count() == 0
)
diff --git a/compliance/test_utils.py b/compliance/test_utils.py
index f1937ea315..5308e719bf 100644
--- a/compliance/test_utils.py
+++ b/compliance/test_utils.py
@@ -33,14 +33,14 @@ def mock_cybersource_wsdl(mocked_responses, settings, service_version=SERVICE_VE
Mocks the responses to achieve a functional WSDL
"""
# in order for zeep to load the wsdl, it will load the wsdl and the accompanying xsd definitions
- with open(f"{DATA_DIR}/CyberSourceTransaction_{service_version}.wsdl") as wsdl: # noqa: PTH123, UP015
+ with open(f"{DATA_DIR}/CyberSourceTransaction_{service_version}.wsdl") as wsdl: # noqa: PTH123
mocked_responses.add(
mocked_responses.GET,
settings.CYBERSOURCE_WSDL_URL,
body=wsdl.read(),
status=status.HTTP_200_OK,
)
- with open(f"{DATA_DIR}/CyberSourceTransaction_{SERVICE_VERSION}.xsd") as xsd: # noqa: PTH123, UP015
+ with open(f"{DATA_DIR}/CyberSourceTransaction_{SERVICE_VERSION}.xsd") as xsd: # noqa: PTH123
mocked_responses.add(
mocked_responses.GET,
f"http://localhost/service/CyberSourceTransaction_{service_version}.xsd",
diff --git a/courses/api.py b/courses/api.py
index 6d1e7136b7..f3a586a540 100644
--- a/courses/api.py
+++ b/courses/api.py
@@ -57,7 +57,7 @@ def get_user_enrollments(user):
for program_enrollment in program_enrollments
)
)
- program_course_ids = {course.id for course in program_courses} # noqa: C401
+ program_course_ids = {course.id for course in program_courses}
course_run_enrollments = (
CourseRunEnrollment.objects.select_related("run__course__coursepage", "company")
.filter(user=user)
@@ -316,7 +316,7 @@ def defer_enrollment(
to_run = CourseRun.objects.get(courseware_id=to_courseware_id)
if from_enrollment.run == to_run:
raise ValidationError(
- f"Cannot defer to the same course run (run: {to_run.courseware_id})" # noqa: EM103, UP032
+ f"Cannot defer to the same course run (run: {to_run.courseware_id})"
)
if not force and not to_run.is_not_beyond_enrollment:
raise ValidationError(
diff --git a/courses/credentials.py b/courses/credentials.py
index 46e0b3b6de..a2a31a621d 100644
--- a/courses/credentials.py
+++ b/courses/credentials.py
@@ -1,7 +1,6 @@
"""Digital courseware credentials"""
import logging
-from typing import Union
from urllib.parse import urljoin
from django.conf import settings
@@ -81,7 +80,7 @@ def build_course_run_credential(certificate: CourseRunCertificate) -> dict:
def build_digital_credential(
- certificate: ProgramCertificate | CourseRunCertificate, # noqa: FA100
+ certificate: ProgramCertificate | CourseRunCertificate,
learner_did: LearnerDID,
) -> dict:
"""Function for building certificate digital credentials"""
diff --git a/courses/management/commands/defer_enrollment.py b/courses/management/commands/defer_enrollment.py
index 28c252de6a..45fe50f451 100644
--- a/courses/management/commands/defer_enrollment.py
+++ b/courses/management/commands/defer_enrollment.py
@@ -63,12 +63,12 @@ def handle(self, *args, **options): # noqa: ARG002
if isinstance(exc, CourseRunEnrollment.DoesNotExist):
message = f"'from' course run enrollment does not exist ({from_courseware_id})"
elif isinstance(exc, CourseRun.DoesNotExist):
- message = f"'to' course does not exist ({to_courseware_id})" # noqa: UP032
+ message = f"'to' course does not exist ({to_courseware_id})"
else:
message = str(exc)
raise CommandError(message) # noqa: B904, TRY200
except ValidationError as exc:
- raise CommandError(f"Invalid enrollment deferral - {exc}") # noqa: B904, EM103, TRY200, UP032
+ raise CommandError(f"Invalid enrollment deferral - {exc}") # noqa: B904, TRY200
else:
if not to_enrollment:
raise CommandError(
diff --git a/courses/management/commands/revoke_certificate.py b/courses/management/commands/revoke_certificate.py
index da06b96c34..37898bbe52 100644
--- a/courses/management/commands/revoke_certificate.py
+++ b/courses/management/commands/revoke_certificate.py
@@ -81,7 +81,7 @@ def handle(self, *args, **options): # noqa: ARG002
if updated:
msg = "Certificate for {} has been {}".format(
- f"run: {run}" if run else f"program: {program}", # noqa: UP032
+ f"run: {run}" if run else f"program: {program}",
"revoked" if revoke else "un-revoked",
)
self.stdout.write(self.style.SUCCESS(msg))
diff --git a/courses/management/commands/sync_grades_and_certificates.py b/courses/management/commands/sync_grades_and_certificates.py
index 20631416bd..7787478ff0 100644
--- a/courses/management/commands/sync_grades_and_certificates.py
+++ b/courses/management/commands/sync_grades_and_certificates.py
@@ -130,10 +130,10 @@ def handle( # noqa: C901, PLR0915
else:
grade_status = "already exists"
- grade_summary = [f"passed: {course_run_grade.passed}"] # noqa: UP032
+ grade_summary = [f"passed: {course_run_grade.passed}"]
if override_grade is not None:
grade_summary.append(
- f"value override: {course_run_grade.grade}" # noqa: UP032
+ f"value override: {course_run_grade.grade}"
)
if created_cert:
diff --git a/courses/management/utils.py b/courses/management/utils.py
index d6d9a676b0..854d146e5c 100644
--- a/courses/management/utils.py
+++ b/courses/management/utils.py
@@ -112,7 +112,7 @@ def fetch_enrollment(user, command_options):
enrollment = CourseRunEnrollment.all_objects.filter(**query_params).first()
if not enrollment:
- raise CommandError(f"Enrollment not found for: {enrolled_obj}") # noqa: EM103, UP032
+ raise CommandError(f"Enrollment not found for: {enrolled_obj}")
if not enrollment.active and not force:
raise CommandError(
"The given enrollment is not active ({}).\n" # noqa: EM103, UP032, RUF100
diff --git a/courses/models.py b/courses/models.py
index 10abee1b48..a71e7a5a78 100644
--- a/courses/models.py
+++ b/courses/models.py
@@ -200,7 +200,7 @@ def catalog_image_url(self):
validate_url_path_field = RegexValidator(
- fr"^[{detail_path_char_pattern}]+$", # noqa: UP032
+ rf"^[{detail_path_char_pattern}]+$",
f"This field is used to produce URL paths. It must contain only characters that match this pattern: [{detail_path_char_pattern}]",
)
diff --git a/courses/serializers.py b/courses/serializers.py
index f8d44de049..ca0f804a78 100644
--- a/courses/serializers.py
+++ b/courses/serializers.py
@@ -350,7 +350,7 @@ def get_instructors(self, instance):
def get_topics(self, instance):
"""List all topics in all courses in the program"""
- topics = { # noqa: C401
+ topics = {
topic.name
for course in instance.courses.all()
if course.page
diff --git a/courses/views_test.py b/courses/views_test.py
index 3360782651..6d344624f3 100644
--- a/courses/views_test.py
+++ b/courses/views_test.py
@@ -283,11 +283,11 @@ def test_course_view( # noqa: PLR0913
class_name = "enrolled"
assert (
- f''.encode() # noqa: UP012
+ f''.encode()
in resp.content
) is has_button
assert (
- b"Please Sign In to MITx PRO to enroll in a course" # noqa: UP012
+ b"Please Sign In to MITx PRO to enroll in a course"
in resp.content
) is (is_anonymous and has_product and has_unexpired_run)
@@ -349,11 +349,11 @@ def test_program_view( # noqa: PLR0913
class_name = "enrolled"
assert (
- f''.encode() # noqa: UP012
+ f''.encode()
in resp.content
) is has_button
assert (
- b"Please Sign In to MITx PRO to enroll in a course" # noqa: UP012
+ b"Please Sign In to MITx PRO to enroll in a course"
in resp.content
) is (is_anonymous and has_product and has_unexpired_run)
diff --git a/courseware/api.py b/courseware/api.py
index af9c309826..fb4c1addd2 100644
--- a/courseware/api.py
+++ b/courseware/api.py
@@ -508,7 +508,7 @@ def get_edx_api_client(user, ttl_in_seconds=OPENEDX_AUTH_DEFAULT_TTL_IN_SECONDS)
auth = get_valid_edx_api_auth(user, ttl_in_seconds=ttl_in_seconds)
except OpenEdxApiAuth.DoesNotExist:
raise NoEdxApiAuthError( # noqa: B904, TRY200
- f"{str(user)} does not have an associated OpenEdxApiAuth" # noqa: EM103, UP032
+ f"{user!s} does not have an associated OpenEdxApiAuth"
)
return EdxApi(
{"access_token": auth.access_token},
@@ -799,7 +799,7 @@ def create_oauth_application():
defaults=dict( # noqa: C408
redirect_uris=urljoin(
settings.OPENEDX_BASE_REDIRECT_URL,
- f"/auth/complete/{settings.MITXPRO_OAUTH_PROVIDER}/", # noqa: UP032
+ f"/auth/complete/{settings.MITXPRO_OAUTH_PROVIDER}/",
),
client_type="confidential",
authorization_grant_type="authorization-code",
diff --git a/ecommerce/api.py b/ecommerce/api.py
index 604b2dd618..bab08ce787 100644
--- a/ecommerce/api.py
+++ b/ecommerce/api.py
@@ -10,9 +10,9 @@
import uuid
from base64 import b64encode
from collections import defaultdict
-from datetime import timedelta
-from typing import NamedTuple, Optional # noqa: UP035
from collections.abc import Iterable
+from datetime import timedelta
+from typing import NamedTuple
from urllib.parse import quote_plus, urljoin
from django.conf import settings
@@ -792,10 +792,9 @@ def enroll_user_in_order_items(order):
):
voucher_target = voucher.product.content_object
voucher_enrollment = first_or_none(
- # noqa: UP034
- enrollment
- for enrollment in successful_run_enrollments
- if enrollment.run == voucher_target
+ enrollment
+ for enrollment in successful_run_enrollments
+ if enrollment.run == voucher_target
)
if voucher_enrollment is not None:
voucher.enrollment = voucher_enrollment
@@ -954,9 +953,9 @@ class ValidatedBasket(NamedTuple):
basket: Basket
basket_item: BasketItem
product_version: ProductVersion
- coupon_version: CouponVersion | None # noqa: FA100
- run_selection_ids: Iterable[int] | None # noqa: FA100
- data_consent_users: Iterable[DataConsentUser] | None # noqa: FA100
+ coupon_version: CouponVersion | None
+ run_selection_ids: Iterable[int] | None
+ data_consent_users: Iterable[DataConsentUser] | None
def _validate_basket_contents(basket):
diff --git a/ecommerce/api_test.py b/ecommerce/api_test.py
index 1b0904d5b9..0577c55d89 100644
--- a/ecommerce/api_test.py
+++ b/ecommerce/api_test.py
@@ -705,9 +705,9 @@ def test_get_by_reference_number(
same_order = Order.objects.get_by_reference_number(order.reference_number)
assert same_order.id == order.id
if hubspot_api_key:
- mock_hubspot_syncs.order.assert_called_with(order.id) # noqa: PGH005
+ mock_hubspot_syncs.order.assert_called_with(order.id)
else:
- mock_hubspot_syncs.order.assert_not_called() # noqa: PGH005
+ mock_hubspot_syncs.order.assert_not_called()
def test_get_by_reference_number_missing(validated_basket):
@@ -771,9 +771,9 @@ def test_create_unfulfilled_order( # noqa: PLR0913
assert CouponRedemption.objects.count() == 0
if hubspot_api_key:
- mock_hubspot_syncs.order.assert_called_with(order.id) # noqa: PGH005
+ mock_hubspot_syncs.order.assert_called_with(order.id)
else:
- mock_hubspot_syncs.order.assert_not_called() # noqa: PGH005
+ mock_hubspot_syncs.order.assert_not_called()
@pytest.mark.parametrize("has_program_run", [True, False])
diff --git a/ecommerce/mail_api_test.py b/ecommerce/mail_api_test.py
index b2c8a1002b..0233f793ba 100644
--- a/ecommerce/mail_api_test.py
+++ b/ecommerce/mail_api_test.py
@@ -159,9 +159,7 @@ def test_send_course_run_enrollment_welcome_email(settings, mocker, enabled):
enrollment = CourseRunEnrollmentFactory.create()
run_start_date = enrollment.run.start_date
- run_start_time = run_start_date.astimezone(datetime.UTC).strftime(
- EMAIL_TIME_FORMAT
- )
+ run_start_time = run_start_date.astimezone(datetime.UTC).strftime(EMAIL_TIME_FORMAT)
run_end_date = enrollment.run.end_date
date_range = (
f"{run_start_date.strftime(EMAIL_DATE_FORMAT)} - "
diff --git a/ecommerce/management/commands/invalidate_payment_coupons.py b/ecommerce/management/commands/invalidate_payment_coupons.py
index bc16df51bd..9df911933d 100644
--- a/ecommerce/management/commands/invalidate_payment_coupons.py
+++ b/ecommerce/management/commands/invalidate_payment_coupons.py
@@ -61,7 +61,7 @@ def handle(self, *args, **kwargs): # noqa: ARG002
codes = Coupon.objects.filter(enabled=True, payment=payment).all()
else:
try:
- with open(kwargs["codefile"]) as file: # noqa: PTH123, UP015
+ with open(kwargs["codefile"]) as file: # noqa: PTH123
procCodes = [line.strip() for line in file]
except Exception as e: # noqa: BLE001
raise CommandError( # noqa: B904, TRY200
diff --git a/ecommerce/views_test.py b/ecommerce/views_test.py
index d22624cb72..f9df1044b4 100644
--- a/ecommerce/views_test.py
+++ b/ecommerce/views_test.py
@@ -225,9 +225,9 @@ def test_zero_price_checkout( # noqa: PLR0913
assert CourseRunSelection.objects.filter(basket__user=user).count() == 0
assert CouponSelection.objects.filter(basket__user=user).count() == 0
if hubspot_api_key:
- mock_hubspot_syncs.order.assert_called_with(order.id) # noqa: PGH005
+ mock_hubspot_syncs.order.assert_called_with(order.id)
else:
- mock_hubspot_syncs.order.assert_not_called() # noqa: PGH005
+ mock_hubspot_syncs.order.assert_not_called()
@pytest.mark.parametrize("hubspot_api_key", [None, "fake-key"])
@@ -287,9 +287,9 @@ def test_order_fulfilled( # noqa: PLR0913
assert CouponSelection.objects.filter(basket__user=user).count() == 0
if hubspot_api_key:
- mock_hubspot_syncs.order.assert_called_with(order.id) # noqa: PGH005
+ mock_hubspot_syncs.order.assert_called_with(order.id)
else:
- mock_hubspot_syncs.order.assert_not_called() # noqa: PGH005
+ mock_hubspot_syncs.order.assert_not_called()
def test_order_affiliate(basket_client, mocker, basket_and_coupons):
diff --git a/localdev/seed/api.py b/localdev/seed/api.py
index d588015f3c..d6d14c2e52 100644
--- a/localdev/seed/api.py
+++ b/localdev/seed/api.py
@@ -207,7 +207,7 @@ def check_settings():
missing.append(variable)
if missing:
raise ImproperlyConfigured(
- f"Missing required voucher settings: {missing}" # noqa: EM103, UP032
+ f"Missing required voucher settings: {missing}"
)
diff --git a/localdev/seed/management/commands/delete_seed_data.py b/localdev/seed/management/commands/delete_seed_data.py
index 268eff4538..f44b0c4640 100644
--- a/localdev/seed/management/commands/delete_seed_data.py
+++ b/localdev/seed/management/commands/delete_seed_data.py
@@ -79,4 +79,4 @@ def handle(self, *args, **options): # noqa: ARG002
else:
self.stdout.write(self.style.SUCCESS("RESULTS"))
for k, v in results.report.items():
- self.stdout.write(f"{k}: {v}") # noqa: UP032
+ self.stdout.write(f"{k}: {v}")
diff --git a/localdev/seed/management/commands/seed_data.py b/localdev/seed/management/commands/seed_data.py
index e6eda3d4d4..0e86e68480 100644
--- a/localdev/seed/management/commands/seed_data.py
+++ b/localdev/seed/management/commands/seed_data.py
@@ -24,4 +24,4 @@ def handle(self, *args, **options): # noqa: ARG002
else:
self.stdout.write(self.style.SUCCESS("RESULTS"))
for k, v in results.report.items():
- self.stdout.write(f"{k}: {v}") # noqa: UP032
+ self.stdout.write(f"{k}: {v}")
diff --git a/mitxpro/models.py b/mitxpro/models.py
index 74d5543e21..e9176a96a8 100644
--- a/mitxpro/models.py
+++ b/mitxpro/models.py
@@ -3,7 +3,7 @@
"""
import copy
-from collections.abc import Iterable # noqa: UP035
+from collections.abc import Iterable
from django.conf import settings
from django.core.exceptions import ValidationError
diff --git a/mitxpro/settings.py b/mitxpro/settings.py
index 4abaf7bfa8..28a7b9b5e7 100644
--- a/mitxpro/settings.py
+++ b/mitxpro/settings.py
@@ -272,7 +272,7 @@
DEFAULT_DATABASE_CONFIG = dj_database_url.parse(
get_string(
name="DATABASE_URL",
- default="sqlite:///{}".format(os.path.join(BASE_DIR, "db.sqlite3")), # noqa: PTH118, UP030
+ default="sqlite:///{}".format(os.path.join(BASE_DIR, "db.sqlite3")), # noqa: PTH118
description="The connection url to the Postgres database",
required=True,
write_app_json=False,
@@ -426,7 +426,7 @@
)
if CLOUDFRONT_DIST:
STATIC_URL = urljoin(
- f"https://{CLOUDFRONT_DIST}.cloudfront.net", # noqa: UP032
+ f"https://{CLOUDFRONT_DIST}.cloudfront.net",
STATIC_URL,
)
@@ -682,7 +682,7 @@
)
if MITXPRO_USE_S3:
if CLOUDFRONT_DIST:
- AWS_S3_CUSTOM_DOMAIN = f"{CLOUDFRONT_DIST}.cloudfront.net" # noqa: UP032
+ AWS_S3_CUSTOM_DOMAIN = f"{CLOUDFRONT_DIST}.cloudfront.net"
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
FEATURES = get_features()
diff --git a/mitxpro/test_utils.py b/mitxpro/test_utils.py
index 688cabc997..3e894c3722 100644
--- a/mitxpro/test_utils.py
+++ b/mitxpro/test_utils.py
@@ -170,7 +170,7 @@ def create_tempfile_csv(rows_iter):
writer = csv.writer(f, delimiter=",")
for row in rows_iter:
writer.writerow(row)
- with open(f.name) as user_csv: # noqa: PTH123, UP015
+ with open(f.name) as user_csv: # noqa: PTH123
return SimpleUploadedFile(
f.name, user_csv.read().encode("utf8"), content_type="application/csv"
)
diff --git a/repl.py b/repl.py
index e310073d98..52ed480a20 100755
--- a/repl.py
+++ b/repl.py
@@ -23,7 +23,7 @@
for app in settings.INSTALLED_APPS:
try: # noqa: SIM105
exec( # noqa: S102
- f"from {app}.models import *" # noqa: UP032
+ f"from {app}.models import *"
)
except ModuleNotFoundError: # noqa: PERF203
pass
diff --git a/sheets/api.py b/sheets/api.py
index f15955575a..1ed5a2039f 100644
--- a/sheets/api.py
+++ b/sheets/api.py
@@ -185,7 +185,7 @@ def get_metadata_for_matching_files(self, query, file_fields="id, name"):
)
return self.pygsheets_client.drive.list(
**extra_list_params,
- fields=f"files({file_fields})", # noqa: UP032
+ fields=f"files({file_fields})",
q=query,
)
diff --git a/sheets/api_test.py b/sheets/api_test.py
index d13aaf8788..86a30df272 100644
--- a/sheets/api_test.py
+++ b/sheets/api_test.py
@@ -26,7 +26,7 @@ def test_get_credentials_service_account(mocker, settings):
get_credentials()
settings.SHEETS_ADMIN_EMAILS.append(
- f"service-account@mitxpro.{GOOGLE_SERVICE_ACCOUNT_EMAIL_DOMAIN}" # noqa: UP032
+ f"service-account@mitxpro.{GOOGLE_SERVICE_ACCOUNT_EMAIL_DOMAIN}"
)
creds = get_credentials()
diff --git a/sheets/coupon_assign_api.py b/sheets/coupon_assign_api.py
index 538f49d7ce..ea47ca967d 100644
--- a/sheets/coupon_assign_api.py
+++ b/sheets/coupon_assign_api.py
@@ -823,7 +823,7 @@ def get_desired_coupon_assignments(cls, assignment_rows):
"codes listed in the Sheet. There may be an invalid coupon code in the Sheet."
)
product_coupon_dict = dict(product_coupon_tuples)
- return {(row.email, product_coupon_dict[row.code]) for row in valid_rows} # noqa: C401
+ return {(row.email, product_coupon_dict[row.code]) for row in valid_rows}
@staticmethod
def get_assignments_to_create_and_remove(
@@ -872,7 +872,7 @@ def get_assignments_to_create_and_remove(
)
# If any of the assignments we want to create have the same product coupon as one
# of these already-redeemed assignments, filter them out and log an info message.
- product_coupon_ids = { # noqa: C401
+ product_coupon_ids = {
assignment.product_coupon_id
for assignment in already_redeemed_assignments
}
@@ -988,7 +988,8 @@ def process_assignment_spreadsheet(self):
# Validate emails before assignment so we can filter out and report on any bad emails
try:
validate_email_addresses(
- assignment_tuple[0] for assignment_tuple in assignments_to_create # noqa: UP034
+ assignment_tuple[0]
+ for assignment_tuple in assignments_to_create
)
except MultiEmailValidationError as exc:
invalid_emails = exc.invalid_emails
diff --git a/sheets/coupon_request_api.py b/sheets/coupon_request_api.py
index 9f26a19974..62948f3638 100644
--- a/sheets/coupon_request_api.py
+++ b/sheets/coupon_request_api.py
@@ -273,7 +273,7 @@ def create_assignment_sheet(self, coupon_req_row):
worksheet = bulk_coupon_sheet.sheet1
# Add headers
worksheet.update_values(
- crange=f"A1:{assign_sheet_metadata.LAST_COL_LETTER}1", # noqa: UP032
+ crange=f"A1:{assign_sheet_metadata.LAST_COL_LETTER}1",
values=[assign_sheet_metadata.column_headers],
)
# Write enrollment codes to the appropriate column of the worksheet
@@ -311,7 +311,7 @@ def create_assignment_sheet(self, coupon_req_row):
# Format header cells with bold text
header_range = worksheet.get_values(
start="A1",
- end=f"{assign_sheet_metadata.LAST_COL_LETTER}1", # noqa: UP032
+ end=f"{assign_sheet_metadata.LAST_COL_LETTER}1",
returnas="range",
)
first_cell = header_range.cells[0][0]
@@ -444,7 +444,7 @@ def process_row(self, row_index, row_data):
row_db_record=coupon_gen_request,
row_object=None,
result_type=ResultType.FAILED,
- message=f"Parsing failure: {str(exc)}", # noqa: UP032
+ message=f"Parsing failure: {exc!s}",
)
is_unchanged_error_row = (
coupon_req_row.errors and not request_created and not request_updated
diff --git a/sheets/deferral_request_api.py b/sheets/deferral_request_api.py
index b2ef84b367..d6df76ddea 100644
--- a/sheets/deferral_request_api.py
+++ b/sheets/deferral_request_api.py
@@ -134,7 +134,7 @@ def process_row( # noqa: C901, PLR0911
row_db_record=deferral_request,
row_object=None,
result_type=ResultType.FAILED,
- message=f"Parsing failure: {str(exc)}", # noqa: UP032
+ message=f"Parsing failure: {exc!s}",
)
is_unchanged_error_row = (
deferral_req_row.errors and not request_created and not request_updated
@@ -202,7 +202,7 @@ def process_row( # noqa: C901, PLR0911
row_db_record=deferral_request,
row_object=None,
result_type=ResultType.FAILED,
- message=f"Invalid deferral: {exc}", # noqa: UP032
+ message=f"Invalid deferral: {exc}",
)
except EdxEnrollmentCreateError as exc:
return RowResult(
@@ -210,7 +210,7 @@ def process_row( # noqa: C901, PLR0911
row_db_record=deferral_request,
row_object=None,
result_type=ResultType.FAILED,
- message=f"Unable to defer enrollment: {exc}", # noqa: UP032
+ message=f"Unable to defer enrollment: {exc}",
)
deferral_request.date_completed = now_in_utc()
diff --git a/sheets/factories.py b/sheets/factories.py
index 6d278c25a5..c7d37cf85f 100644
--- a/sheets/factories.py
+++ b/sheets/factories.py
@@ -29,12 +29,8 @@ class Meta:
class GoogleFileWatchFactory(DjangoModelFactory):
file_id = Faker("pystr", max_chars=15)
channel_id = fuzzy.FuzzyText(prefix="Channel ")
- activation_date = Faker(
- "past_datetime", start_date="-30d", tzinfo=datetime.UTC
- )
- expiration_date = Faker(
- "future_datetime", end_date="+30d", tzinfo=datetime.UTC
- )
+ activation_date = Faker("past_datetime", start_date="-30d", tzinfo=datetime.UTC)
+ expiration_date = Faker("future_datetime", end_date="+30d", tzinfo=datetime.UTC)
class Meta:
model = models.GoogleFileWatch
diff --git a/sheets/mail_api.py b/sheets/mail_api.py
index 4f58cff220..ec117f73ac 100644
--- a/sheets/mail_api.py
+++ b/sheets/mail_api.py
@@ -69,8 +69,8 @@ def get_bulk_assignment_messages(event=None, begin=None, end=None):
raw_next_url = resp_data["paging"]["next"]
# The "next" url in the paging section does not contain necessary auth. Fill it in here.
url = raw_next_url.replace(
- f"/{MAILGUN_API_DOMAIN}/", # noqa: UP032
- f"/api:{settings.MAILGUN_KEY}@{MAILGUN_API_DOMAIN}/", # noqa: UP032
+ f"/{MAILGUN_API_DOMAIN}/",
+ f"/api:{settings.MAILGUN_KEY}@{MAILGUN_API_DOMAIN}/",
)
resp = request_get_with_timeout_retry(
url, retries=MAILGUN_API_TIMEOUT_RETRIES
diff --git a/sheets/management/commands/process_coupon_requests.py b/sheets/management/commands/process_coupon_requests.py
index a65202a84d..5f5160c120 100644
--- a/sheets/management/commands/process_coupon_requests.py
+++ b/sheets/management/commands/process_coupon_requests.py
@@ -28,5 +28,5 @@ def handle(self, *args, **options): # noqa: ARG002
limit_row_index=options.get("row", None)
)
self.stdout.write(
- self.style.SUCCESS(f"Coupon generation succeeded.\n{results}") # noqa: UP032
+ self.style.SUCCESS(f"Coupon generation succeeded.\n{results}")
)
diff --git a/sheets/management/commands/process_deferral_requests.py b/sheets/management/commands/process_deferral_requests.py
index eba8e5408e..780c404833 100644
--- a/sheets/management/commands/process_deferral_requests.py
+++ b/sheets/management/commands/process_deferral_requests.py
@@ -29,6 +29,6 @@ def handle(self, *args, **options): # noqa: ARG002
)
self.stdout.write(
self.style.SUCCESS(
- f"Deferral sheet successfully processed.\n{results}" # noqa: UP032
+ f"Deferral sheet successfully processed.\n{results}"
)
)
diff --git a/sheets/management/commands/process_refund_requests.py b/sheets/management/commands/process_refund_requests.py
index 1b86920162..db7b2184bb 100644
--- a/sheets/management/commands/process_refund_requests.py
+++ b/sheets/management/commands/process_refund_requests.py
@@ -29,6 +29,6 @@ def handle(self, *args, **options): # noqa: ARG002
)
self.stdout.write(
self.style.SUCCESS(
- f"Refund sheet successfully processed.\n{results}" # noqa: UP032
+ f"Refund sheet successfully processed.\n{results}"
)
)
diff --git a/sheets/management/commands/setup_file_watch.py b/sheets/management/commands/setup_file_watch.py
index e9b3fd66fc..0160fed025 100644
--- a/sheets/management/commands/setup_file_watch.py
+++ b/sheets/management/commands/setup_file_watch.py
@@ -135,7 +135,7 @@ def handle( # noqa: C901
else f"\n[{renewal_attempt.result_status_code}] {renewal_attempt.result}"
)
self.style.ERROR(
- f"Failed to create/update file watch.{error_msg}" # noqa: UP032
+ f"Failed to create/update file watch.{error_msg}"
)
continue
if file_watch_result.created:
@@ -146,7 +146,7 @@ def handle( # noqa: C901
desc = "found (unexpired)"
file_id_desc = ""
if file_watch_result.metadata.sheet_type == SHEET_TYPE_COUPON_ASSIGN:
- file_id_desc = f" (file id: {file_watch.file_id})" # noqa: UP032
+ file_id_desc = f" (file id: {file_watch.file_id})"
self.stdout.write(
self.style.SUCCESS(
@@ -193,7 +193,7 @@ def handle( # noqa: C901
)
else:
self.stdout.write(
- self.style.ERROR(f"Request failed: {exc}") # noqa: UP032
+ self.style.ERROR(f"Request failed: {exc}")
)
sys.exit(1)
else:
diff --git a/sheets/migrations/0010_fill_in_gen_request_coupon_name.py b/sheets/migrations/0010_fill_in_gen_request_coupon_name.py
index 5b4b140e85..05f623cc18 100644
--- a/sheets/migrations/0010_fill_in_gen_request_coupon_name.py
+++ b/sheets/migrations/0010_fill_in_gen_request_coupon_name.py
@@ -29,7 +29,7 @@ def fill_in_coupon_name(apps, schema_editor):
"raw_data is either not a list, or does not include a valid coupon name" # noqa: EM101
)
except Exception: # noqa: BLE001
- coupon_name = f"COUPON NAME NEEDED ({coupon_gen_request.id})" # noqa: UP032
+ coupon_name = f"COUPON NAME NEEDED ({coupon_gen_request.id})"
else:
coupon_name = raw_data[1]
coupon_gen_request.coupon_name = coupon_name
diff --git a/sheets/refund_request_api.py b/sheets/refund_request_api.py
index 83ab3db3a0..9b951acf8e 100644
--- a/sheets/refund_request_api.py
+++ b/sheets/refund_request_api.py
@@ -226,7 +226,7 @@ def process_row(self, row_index, row_data):
row_db_record=refund_request,
row_object=None,
result_type=ResultType.FAILED,
- message=f"Parsing failure: {str(exc)}", # noqa: UP032
+ message=f"Parsing failure: {exc!s}",
)
is_unchanged_error_row = (
refund_req_row.errors and not request_created and not request_updated
diff --git a/sheets/sheet_handler_api.py b/sheets/sheet_handler_api.py
index a16be6897c..5331ae2fa8 100644
--- a/sheets/sheet_handler_api.py
+++ b/sheets/sheet_handler_api.py
@@ -214,7 +214,7 @@ def process_sheet(self, limit_row_index=None):
row_db_record=None,
row_object=None,
result_type=ResultType.FAILED,
- message=f"Error: {str(exc)}", # noqa: UP032
+ message=f"Error: {exc!s}",
)
finally:
if row_result:
diff --git a/sheets/utils.py b/sheets/utils.py
index 7e5bdcb6d6..ecf3653770 100644
--- a/sheets/utils.py
+++ b/sheets/utils.py
@@ -460,7 +460,7 @@ def _parse_sheet_date_str(date_str, date_format):
)
return (
dt
- if settings.SHEETS_DATE_TIMEZONE == datetime.UTC # noqa: SIM300
+ if settings.SHEETS_DATE_TIMEZONE == datetime.UTC
else dt.astimezone(datetime.UTC)
)
diff --git a/users/api.py b/users/api.py
index 05672be0e5..91300385e5 100644
--- a/users/api.py
+++ b/users/api.py
@@ -75,7 +75,7 @@ def fetch_user(filter_value, ignore_case=True): # noqa: FBT002
filter_field = _determine_filter_field(filter_value)
if _is_case_insensitive_searchable(filter_field) and ignore_case:
- query = {f"{filter_field}__iexact": filter_value} # noqa: UP032
+ query = {f"{filter_field}__iexact": filter_value}
else:
query = {filter_field: filter_value}
try:
@@ -125,14 +125,14 @@ def fetch_users(filter_values, ignore_case=True): # noqa: FBT002
query = reduce(
operator.or_,
(
- Q(**{f"{filter_field}__iexact": filter_value}) # noqa: UP032
+ Q(**{f"{filter_field}__iexact": filter_value})
for filter_value in filter_values
),
)
user_qset = User.objects.filter(query)
else:
user_qset = User.objects.filter(
- **{f"{filter_field}__in": filter_values} # noqa: UP032
+ **{f"{filter_field}__in": filter_values}
)
if user_qset.count() != len(filter_values):
valid_values = user_qset.values_list(filter_field, flat=True)
@@ -184,7 +184,7 @@ def find_available_username(initial_username_base):
]
# Find usernames that match the username base and have a numerical suffix, then find the max suffix
existing_usernames = User.objects.filter(
- username__regex=fr"{username_base}[0-9]+" # noqa: UP032
+ username__regex=rf"{username_base}[0-9]+"
).values_list("username", flat=True)
max_suffix = max_or_none(
int(re.search(r"\d+$", username).group()) for username in existing_usernames
diff --git a/users/management/commands/retire_users.py b/users/management/commands/retire_users.py
index 0747b084e5..66d578545d 100644
--- a/users/management/commands/retire_users.py
+++ b/users/management/commands/retire_users.py
@@ -92,7 +92,7 @@ def handle(self, *args, **kwargs): # noqa: ARG002
users = fetch_users(kwargs["users"])
for user in users:
- self.stdout.write(f"Retiring user: {user}") # noqa: UP032
+ self.stdout.write(f"Retiring user: {user}")
if not user.is_active:
self.stdout.write(
self.style.ERROR(
@@ -126,11 +126,11 @@ def handle(self, *args, **kwargs): # noqa: ARG002
if auth_deleted_count:
self.stdout.write(
- f"For user: '{user}' SocialAuth rows deleted" # noqa: UP032
+ f"For user: '{user}' SocialAuth rows deleted"
)
self.stdout.write(
self.style.SUCCESS(
- f"User: '{user}' is retired from MIT xPRO" # noqa: UP032
+ f"User: '{user}' is retired from MIT xPRO"
)
)