Skip to content

Commit

Permalink
fix: python 3.8 typing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarIthawi authored and andrey-canon committed Dec 3, 2024
1 parent fcff67a commit 0f6e86c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lms/djangoapps/mobile_api/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import logging
from functools import cached_property
from typing import Optional
from typing import Optional, List

from completion.exceptions import UnavailableCompletionData
from completion.utilities import get_key_to_last_completed_block
Expand Down Expand Up @@ -410,7 +410,7 @@ def get_queryset(self):
# return all courses, with associated expiration
return mobile_available

def get_same_org_mobile_available_enrollments(self) -> list[CourseEnrollment]:
def get_same_org_mobile_available_enrollments(self) -> List[CourseEnrollment]:
"""
Gets list with `CourseEnrollment` for mobile available courses.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from __future__ import annotations

from typing import List

from rest_framework import serializers, fields

from openedx_tagging.core.tagging.rest_api.v1.serializers import (
Expand Down Expand Up @@ -72,7 +74,7 @@ class TaxonomyOrgSerializer(TaxonomySerializer):
orgs = serializers.SerializerMethodField()
all_orgs = serializers.SerializerMethodField()

def get_orgs(self, obj) -> list[str]:
def get_orgs(self, obj) -> List[str]:
"""
Return the list of orgs for the taxonomy.
"""
Expand Down
12 changes: 6 additions & 6 deletions openedx/core/djangoapps/content_tagging/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import Union
from typing import Union, List

import django.contrib.auth.models
import openedx_tagging.core.tagging.rules as oel_tagging
Expand Down Expand Up @@ -41,7 +41,7 @@ def is_org_user(user: UserType, orgs: list[Organization]) -> bool:
return len(get_user_orgs(user, orgs)) > 0


def get_admin_orgs(user: UserType, orgs: list[Organization] | None = None) -> list[Organization]:
def get_admin_orgs(user: UserType, orgs: list[Organization] | None = None) -> List[Organization]:
"""
Returns a list of orgs that the given user is an org-level staff, from the given list of orgs.
Expand All @@ -53,7 +53,7 @@ def get_admin_orgs(user: UserType, orgs: list[Organization] | None = None) -> li
]


def _get_content_creator_orgs(user: UserType, orgs: list[Organization]) -> list[Organization]:
def _get_content_creator_orgs(user: UserType, orgs: list[Organization]) -> List[Organization]:
"""
Returns a list of orgs that the given user is an org-level library user or instructor, from the given list of orgs.
"""
Expand All @@ -66,7 +66,7 @@ def _get_content_creator_orgs(user: UserType, orgs: list[Organization]) -> list[
]


def _get_course_user_orgs(user: UserType, orgs: list[Organization]) -> list[Organization]:
def _get_course_user_orgs(user: UserType, orgs: list[Organization]) -> List[Organization]:
"""
Returns a list of orgs for courses where the given user is staff or instructor, from the given list of orgs.
Expand Down Expand Up @@ -97,7 +97,7 @@ def user_has_role_ignore_course_id(user, role_name, org_name) -> bool:
]


def _get_library_user_orgs(user: UserType, orgs: list[Organization]) -> list[Organization]:
def _get_library_user_orgs(user: UserType, orgs: list[Organization]) -> List[Organization]:
"""
Returns a list of orgs (from the given list of orgs) that are associated with libraries that the given user has
explicitly been granted access to.
Expand All @@ -110,7 +110,7 @@ def _get_library_user_orgs(user: UserType, orgs: list[Organization]) -> list[Org
return list(set(library_orgs).intersection(orgs))


def get_user_orgs(user: UserType, orgs: list[Organization] | None = None) -> list[Organization]:
def get_user_orgs(user: UserType, orgs: list[Organization] | None = None) -> List[Organization]:
"""
Return a list of orgs that the given user is a member of (instructor or content creator),
from the given list of orgs.
Expand Down
6 changes: 4 additions & 2 deletions openedx/core/djangoapps/content_tagging/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"""
from __future__ import annotations

from typing import List

from edx_django_utils.cache import RequestCache
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey, UsageKey
Expand Down Expand Up @@ -89,7 +91,7 @@ def clear(self):
"""
self.request_cache.clear()

def get_orgs(self, org_names: list[str] | None = None) -> list[Organization]:
def get_orgs(self, org_names: list[str] | None = None) -> List[Organization]:
"""
Returns the Organizations with the given name(s), or all Organizations if no names given.
Expand All @@ -111,7 +113,7 @@ def get_orgs(self, org_names: list[str] | None = None) -> list[Organization]:

return all_orgs.values()

def get_library_orgs(self, user, org_names: list[str]) -> list[Organization]:
def get_library_orgs(self, user, org_names: list[str]) -> List[Organization]:
"""
Returns the Organizations that are associated with libraries that the given user has explicitly been granted
access to.
Expand Down

0 comments on commit 0f6e86c

Please sign in to comment.