Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -14,11 +14,11 @@ repos:
- id: check-toml
- id: debug-statements
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.11.0-1
rev: v3.12.0-2
hooks:
- id: shfmt
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.37.0
rev: v1.37.1
hooks:
- id: yamllint
args: [--format, parsable, -d, relaxed]
Expand Down Expand Up @@ -47,15 +47,15 @@ repos:
- "config/keycloak/*"
additional_dependencies: ["gibberish-detector"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.11.7"
rev: "v0.13.3"
hooks:
- id: ruff-format
- id: ruff
args:
- --extend-ignore=D1
- --fix
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
rev: v0.11.0.1
hooks:
- id: shellcheck
args: ["--severity=warning"]
Expand Down
4 changes: 2 additions & 2 deletions authentication/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ def process_exception(self, request, exception):
if strategy is None or self.raise_exception(request, exception):
return None

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

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

if url: # noqa: RET503
if url:
url += (
("?" in url and "&") or "?"
) + f"message={quote(message)}&backend={backend_name}"
Expand Down
2 changes: 1 addition & 1 deletion cms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Meta:
def video_player_config(self):
"""Get configuration for video player"""

if self.video_url: # noqa: RET503
if self.video_url:
config = {"techOrder": ["html5"], "sources": [{"src": self.video_url}]}
try:
embed = get_embed(self.video_url)
Expand Down
4 changes: 2 additions & 2 deletions cms/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def queue_fastly_purge_url(page_id):
logger.info("Purge request processed OK.")
return True

logger.error("Purge request failed.") # noqa: RET503
logger.error("Purge request failed.")


@app.task()
Expand All @@ -96,7 +96,7 @@ def queue_fastly_full_purge():
logger.info("Purge request processed OK.")
return True

logger.error("Purge request failed.") # noqa: RET503
logger.error("Purge request failed.")


@app.task
Expand Down
4 changes: 1 addition & 3 deletions courses/serializers/v1/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

from typing import Optional

from drf_spectacular.utils import extend_schema_field
from rest_framework import serializers

Expand Down Expand Up @@ -47,7 +45,7 @@ class BaseCourseRunSerializer(serializers.ModelSerializer):
course_number = serializers.SerializerMethodField()
courseware_url = serializers.SerializerMethodField()

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

Expand Down
2 changes: 1 addition & 1 deletion courses/views/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def get_serializer_context(self):

def _validate_enrollment_post_request(
request: Request,
) -> Union[Tuple[Optional[HttpResponse], None, None], Tuple[None, User, CourseRun]]: # noqa: UP006
) -> Union[Tuple[HttpResponse | None, None, None], Tuple[None, User, CourseRun]]: # noqa: UP006
"""
Validates a request to create an enrollment. Returns a response if validation fails, or a user and course run
if validation succeeds.
Expand Down
4 changes: 2 additions & 2 deletions ecommerce/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import uuid
from datetime import datetime
from decimal import Decimal
from typing import List, Optional # noqa: UP035
from typing import List # noqa: UP035

import pytz
import reversion
Expand Down Expand Up @@ -804,7 +804,7 @@ def create_from_basket(cls, basket: Basket):

@classmethod
def create_from_product(
cls, product: Product, user: User, discount: Optional[Discount] = None
cls, product: Product, user: User, discount: Discount | None = None
):
"""
Creates a new pending order from a product
Expand Down
2 changes: 1 addition & 1 deletion flexiblepricing/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def get_courseware_object(self, instance):
program_content_type = ContentType.objects.get(
app_label="courses", model="program"
).id
if instance["courseware_content_type"] == course_content_type: # noqa: RET503
if instance["courseware_content_type"] == course_content_type:
return BaseCourseSerializer(
Course.objects.filter(id=instance["courseware_object_id"]).first()
).data
Expand Down
2 changes: 1 addition & 1 deletion hubspot_sync/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ def get_hubspot_id_for_object( # noqa: C901
serialized_product["name"],
raise_count_error=raise_error,
)
if hubspot_obj and hubspot_obj.id: # noqa: RET503
if hubspot_obj and hubspot_obj.id:
try:
HubspotObject.objects.update_or_create(
object_id=obj.id,
Expand Down
10 changes: 5 additions & 5 deletions hubspot_sync/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ def get_status(self, instance):
def get_product_id(self, instance):
"""Return the product version text_id"""
product = self._get_product(instance)
if product: # noqa: RET503
if product:
return product.purchasable_object.readable_id

def get_price(self, instance):
"""Get the product version price"""
product = self._get_product(instance)
if product: # noqa: RET503
if product:
return format_decimal(product.price)

class Meta:
Expand Down Expand Up @@ -182,13 +182,13 @@ def get_dealstage(self, instance):

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

def get_discount_type(self, instance):
"""Get the discount type of the applied coupon"""
discount = self._get_discount(instance)
if discount: # noqa: RET503
if discount:
return discount.discount_type

def get_amount(self, instance):
Expand Down Expand Up @@ -230,7 +230,7 @@ def get_discount_percent(self, instance):
def get_coupon_code(self, instance):
"""Get the coupon code used for the order if any"""
discount = self._get_discount(instance)
if discount: # noqa: RET503
if discount:
return discount.discount_code

class Meta:
Expand Down
3 changes: 1 addition & 2 deletions main/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from __future__ import annotations

import logging
from typing import Optional

from django.conf import settings
from opentelemetry import trace
Expand All @@ -23,7 +22,7 @@
log = logging.getLogger(__name__)


def configure_opentelemetry() -> Optional[TracerProvider]:
def configure_opentelemetry() -> TracerProvider | None:
"""
Configure OpenTelemetry with appropriate instrumentations and exporters.
Returns the tracer provider if configured, None otherwise.
Expand Down
4 changes: 2 additions & 2 deletions main/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import json
from datetime import date, datetime
from typing import TYPE_CHECKING, Optional, Set, Tuple, TypeVar, Union # noqa: UP035
from typing import TYPE_CHECKING, Set, Tuple, TypeVar, Union # noqa: UP035
from urllib.parse import quote_plus

import dateutil
Expand Down Expand Up @@ -200,7 +200,7 @@ def now_datetime_with_tz():
return datetime.now(tz=pytz.timezone(settings.TIME_ZONE))


def date_to_datetime(date: date, tzinfo: Optional[str] = None) -> datetime:
def date_to_datetime(date: date, tzinfo: str | None = None) -> datetime:
"""Convert a regular date to a datetime with optiona timezone info."""

ret_date = datetime.fromisocalendar(*date.isocalendar())
Expand Down
Loading