Skip to content

Commit f409e0a

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

File tree

12 files changed

+21
-24
lines changed

12 files changed

+21
-24
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
@@ -98,7 +98,7 @@ class Meta:
9898
def video_player_config(self):
9999
"""Get configuration for video player"""
100100

101-
if self.video_url: # noqa: RET503
101+
if self.video_url:
102102
config = {"techOrder": ["html5"], "sources": [{"src": self.video_url}]}
103103
try:
104104
embed = get_embed(self.video_url)

cms/tasks.py

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

81-
logger.error("Purge request failed.") # noqa: RET503
81+
logger.error("Purge request failed.")
8282

8383

8484
@app.task()
@@ -98,7 +98,7 @@ def queue_fastly_full_purge():
9898
logger.info("Purge request processed OK.")
9999
return True
100100

101-
logger.error("Purge request failed.") # noqa: RET503
101+
logger.error("Purge request failed.")
102102

103103

104104
@app.task

courses/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ def _has_earned_program_cert(user, program):
846846
root = ProgramRequirement.get_root_nodes().get(program=program)
847847

848848
def _has_earned(node):
849-
if node.is_root or node.is_all_of_operator: # noqa: RET503
849+
if node.is_root or node.is_all_of_operator:
850850
# has passed all of the child requirements
851851
return all(_has_earned(child) for child in node.get_children())
852852
elif node.is_min_number_of_operator:

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
@@ -259,7 +259,7 @@ def get_serializer_context(self):
259259

260260
def _validate_enrollment_post_request(
261261
request: Request,
262-
) -> Union[Tuple[Optional[HttpResponse], None, None], Tuple[None, User, CourseRun]]: # noqa: UP006
262+
) -> Union[Tuple[HttpResponse | None, None, None], Tuple[None, User, CourseRun]]: # noqa: UP006
263263
"""
264264
Validates a request to create an enrollment. Returns a response if validation fails, or a user and course run
265265
if validation succeeds.

ecommerce/models.py

Lines changed: 3 additions & 3 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
@@ -391,7 +391,7 @@ def discount_product(self, product, user=None):
391391
"""
392392
from ecommerce.discounts import DiscountType
393393

394-
if (user is None and self.valid_now()) or self.check_validity(user): # noqa: RET503
394+
if (user is None and self.valid_now()) or self.check_validity(user):
395395
return DiscountType.get_discounted_price([self], product).quantize(
396396
Decimal("0.01")
397397
)
@@ -775,7 +775,7 @@ def create_from_basket(cls, basket: Basket):
775775

776776
@classmethod
777777
def create_from_product(
778-
cls, product: Product, user: User, discount: Optional[Discount] = None
778+
cls, product: Product, user: User, discount: Discount | None = None
779779
):
780780
"""
781781
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
@@ -536,7 +536,7 @@ def get_hubspot_id_for_object( # noqa: C901
536536
serialized_product["name"],
537537
raise_count_error=raise_error,
538538
)
539-
if hubspot_obj and hubspot_obj.id: # noqa: RET503
539+
if hubspot_obj and hubspot_obj.id:
540540
try:
541541
HubspotObject.objects.update_or_create(
542542
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:

0 commit comments

Comments
 (0)