From 5461fa15908c8ebbafedc62afe97221d0c9236ef Mon Sep 17 00:00:00 2001 From: Maria Grimaldi Date: Wed, 4 Dec 2024 13:26:54 +0100 Subject: [PATCH] refactor: add type hints to filter/order functions --- cms/djangoapps/contentstore/views/course.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cms/djangoapps/contentstore/views/course.py b/cms/djangoapps/contentstore/views/course.py index b0899b60a953..841a3ca38756 100644 --- a/cms/djangoapps/contentstore/views/course.py +++ b/cms/djangoapps/contentstore/views/course.py @@ -15,6 +15,7 @@ from django.contrib.auth import get_user_model from django.contrib.auth.decorators import login_required from django.core.exceptions import FieldError, PermissionDenied, ValidationError as DjangoValidationError +from django.db.models import QuerySet from django.http import Http404, HttpResponse, HttpResponseBadRequest, HttpResponseNotFound from django.shortcuts import redirect from django.urls import reverse @@ -592,7 +593,7 @@ def filter_ccx(course_access): return courses_list, [] -def get_courses_by_status(active_only, archived_only, course_overviews): +def get_courses_by_status(active_only: bool, archived_only: bool, course_overviews: QuerySet[CourseOverview]): """ Return course overviews based on a base queryset filtered by a status. @@ -606,7 +607,7 @@ def get_courses_by_status(active_only, archived_only, course_overviews): return CourseOverview.get_courses_by_status(active_only, archived_only, course_overviews) -def get_courses_by_search_query(search_query, course_overviews): +def get_courses_by_search_query(search_query: str | None, course_overviews: QuerySet[CourseOverview]): """Return course overviews based on a base queryset filtered by a search query. Args: @@ -618,7 +619,7 @@ def get_courses_by_search_query(search_query, course_overviews): return CourseOverview.get_courses_matching_query(search_query, course_overviews=course_overviews) -def get_courses_order_by(order_query, course_overviews): +def get_courses_order_by(order_query: str | None, course_overviews: QuerySet[CourseOverview]): """Return course overviews based on a base queryset ordered by a query. Args: