Skip to content

Commit a3e6045

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent d20cb8b commit a3e6045

File tree

11 files changed

+19
-22
lines changed

11 files changed

+19
-22
lines changed

authentication/middleware.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ def process_exception(self, request, exception):
2222
if strategy is None or self.raise_exception(request, exception):
2323
return None
2424

25-
if isinstance(exception, SocialAuthBaseException): # noqa: RET503
25+
if isinstance(exception, SocialAuthBaseException):
2626
backend = getattr(request, "backend", None)
2727
backend_name = getattr(backend, "name", "unknown-backend")
2828

2929
message = self.get_message(request, exception)
3030
url = self.get_redirect_uri(request, exception)
3131

32-
if url: # noqa: RET503
32+
if url:
3333
url += (
3434
("?" in url and "&") or "?"
3535
) + f"message={quote(message)}&backend={backend_name}"

cms/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class Meta:
102102
def video_player_config(self):
103103
"""Get configuration for video player"""
104104

105-
if self.video_url: # noqa: RET503
105+
if self.video_url:
106106
config = {"techOrder": ["html5"], "sources": [{"src": self.video_url}]}
107107
try:
108108
embed = get_embed(self.video_url)

cms/tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def queue_fastly_purge_url(page_id):
7676
logger.info("Purge request processed OK.")
7777
return True
7878

79-
logger.error("Purge request failed.") # noqa: RET503
79+
logger.error("Purge request failed.")
8080

8181

8282
@app.task()
@@ -96,7 +96,7 @@ def queue_fastly_full_purge():
9696
logger.info("Purge request processed OK.")
9797
return True
9898

99-
logger.error("Purge request failed.") # noqa: RET503
99+
logger.error("Purge request failed.")
100100

101101

102102
@app.task

courses/serializers/v1/base.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from __future__ import annotations
22

3-
from typing import Optional
4-
53
from drf_spectacular.utils import extend_schema_field
64
from rest_framework import serializers
75

@@ -47,7 +45,7 @@ class BaseCourseRunSerializer(serializers.ModelSerializer):
4745
course_number = serializers.SerializerMethodField()
4846
courseware_url = serializers.SerializerMethodField()
4947

50-
def get_courseware_url(self, instance) -> Optional[str]:
48+
def get_courseware_url(self, instance) -> str | None:
5149
"""Get the courseware URL"""
5250
return instance.courseware_url
5351

courses/views/v1/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def get_serializer_context(self):
269269

270270
def _validate_enrollment_post_request(
271271
request: Request,
272-
) -> Union[Tuple[Optional[HttpResponse], None, None], Tuple[None, User, CourseRun]]: # noqa: UP006
272+
) -> Union[Tuple[HttpResponse | None, None, None], Tuple[None, User, CourseRun]]: # noqa: UP006
273273
"""
274274
Validates a request to create an enrollment. Returns a response if validation fails, or a user and course run
275275
if validation succeeds.

ecommerce/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import uuid
55
from datetime import datetime
66
from decimal import Decimal
7-
from typing import List, Optional # noqa: UP035
7+
from typing import List # noqa: UP035
88

99
import pytz
1010
import reversion
@@ -804,7 +804,7 @@ def create_from_basket(cls, basket: Basket):
804804

805805
@classmethod
806806
def create_from_product(
807-
cls, product: Product, user: User, discount: Optional[Discount] = None
807+
cls, product: Product, user: User, discount: Discount | None = None
808808
):
809809
"""
810810
Creates a new pending order from a product

flexiblepricing/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def get_courseware_object(self, instance):
207207
program_content_type = ContentType.objects.get(
208208
app_label="courses", model="program"
209209
).id
210-
if instance["courseware_content_type"] == course_content_type: # noqa: RET503
210+
if instance["courseware_content_type"] == course_content_type:
211211
return BaseCourseSerializer(
212212
Course.objects.filter(id=instance["courseware_object_id"]).first()
213213
).data

hubspot_sync/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ def get_hubspot_id_for_object( # noqa: C901
535535
serialized_product["name"],
536536
raise_count_error=raise_error,
537537
)
538-
if hubspot_obj and hubspot_obj.id: # noqa: RET503
538+
if hubspot_obj and hubspot_obj.id:
539539
try:
540540
HubspotObject.objects.update_or_create(
541541
object_id=obj.id,

hubspot_sync/serializers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ def get_status(self, instance):
103103
def get_product_id(self, instance):
104104
"""Return the product version text_id"""
105105
product = self._get_product(instance)
106-
if product: # noqa: RET503
106+
if product:
107107
return product.purchasable_object.readable_id
108108

109109
def get_price(self, instance):
110110
"""Get the product version price"""
111111
product = self._get_product(instance)
112-
if product: # noqa: RET503
112+
if product:
113113
return format_decimal(product.price)
114114

115115
class Meta:
@@ -182,13 +182,13 @@ def get_dealstage(self, instance):
182182

183183
def get_closedate(self, instance):
184184
"""Return the updated_on date (as a timestamp in milliseconds) if fulfilled"""
185-
if instance.state == models.OrderStatus.FULFILLED: # noqa: RET503
185+
if instance.state == models.OrderStatus.FULFILLED:
186186
return int(instance.updated_on.timestamp() * 1000)
187187

188188
def get_discount_type(self, instance):
189189
"""Get the discount type of the applied coupon"""
190190
discount = self._get_discount(instance)
191-
if discount: # noqa: RET503
191+
if discount:
192192
return discount.discount_type
193193

194194
def get_amount(self, instance):
@@ -230,7 +230,7 @@ def get_discount_percent(self, instance):
230230
def get_coupon_code(self, instance):
231231
"""Get the coupon code used for the order if any"""
232232
discount = self._get_discount(instance)
233-
if discount: # noqa: RET503
233+
if discount:
234234
return discount.discount_code
235235

236236
class Meta:

main/telemetry.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from __future__ import annotations
44

55
import logging
6-
from typing import Optional
76

87
from django.conf import settings
98
from opentelemetry import trace
@@ -23,7 +22,7 @@
2322
log = logging.getLogger(__name__)
2423

2524

26-
def configure_opentelemetry() -> Optional[TracerProvider]:
25+
def configure_opentelemetry() -> TracerProvider | None:
2726
"""
2827
Configure OpenTelemetry with appropriate instrumentations and exporters.
2928
Returns the tracer provider if configured, None otherwise.

0 commit comments

Comments
 (0)