From a013c08ae6beea4e3e8ef91cb12ffe32af5b9b33 Mon Sep 17 00:00:00 2001 From: Braden MacDonald Date: Mon, 28 Aug 2023 10:34:08 -0700 Subject: [PATCH] fix: incorrect type hints in a few places (#33104) --- .../content/learning_sequences/api/processors/schedule.py | 7 ++++--- openedx/core/djangoapps/content_staging/data.py | 2 +- xmodule/partitions/partitions_service.py | 5 ++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openedx/core/djangoapps/content/learning_sequences/api/processors/schedule.py b/openedx/core/djangoapps/content/learning_sequences/api/processors/schedule.py index 643559e51a..7d6e373b43 100644 --- a/openedx/core/djangoapps/content/learning_sequences/api/processors/schedule.py +++ b/openedx/core/djangoapps/content/learning_sequences/api/processors/schedule.py @@ -1,11 +1,12 @@ # lint-amnesty, pylint: disable=missing-module-docstring +from __future__ import annotations + import logging from collections import defaultdict # lint-amnesty, pylint: disable=unused-import from datetime import datetime, timedelta -from typing import Dict from edx_when.api import get_dates_for_course -from opaque_keys.edx.keys import CourseKey # lint-amnesty, pylint: disable=unused-import +from opaque_keys.edx.keys import UsageKey, CourseKey # lint-amnesty, pylint: disable=unused-import from openedx.core import types from common.djangoapps.student.auth import user_has_role @@ -37,7 +38,7 @@ class ScheduleOutlineProcessor(OutlineProcessor): def __init__(self, course_key: CourseKey, user: types.User, at_time: datetime): super().__init__(course_key, user, at_time) self.dates = None - self.keys_to_schedule_fields: Dict[str, Dict[str, datetime]] = defaultdict(dict) + self.keys_to_schedule_fields: dict[UsageKey, dict[str, datetime]] = defaultdict(dict) self._course_start = None self._course_end = None self._is_beta_tester = False diff --git a/openedx/core/djangoapps/content_staging/data.py b/openedx/core/djangoapps/content_staging/data.py index a33dcca470..4f42de9c6e 100644 --- a/openedx/core/djangoapps/content_staging/data.py +++ b/openedx/core/djangoapps/content_staging/data.py @@ -63,4 +63,4 @@ class StagedContentFileData: class UserClipboardData: """ Read-only data model for User Clipboard data (copied OLX) """ content: StagedContentData = field(validator=validators.instance_of(StagedContentData)) - source_usage_key: UsageKey = field(validator=validators.instance_of(UsageKey)) + source_usage_key: UsageKey = field(validator=validators.instance_of(UsageKey)) # type: ignore[type-abstract] diff --git a/xmodule/partitions/partitions_service.py b/xmodule/partitions/partitions_service.py index 57fd8b61ae..e0d976dad7 100644 --- a/xmodule/partitions/partitions_service.py +++ b/xmodule/partitions/partitions_service.py @@ -3,13 +3,12 @@ This is a service-like API that assigns tracks which groups users are in for var user partitions. It uses the user_service key/value store provided by the LMS runtime to persist the assignments. """ - - import logging from typing import Dict from django.conf import settings from django.contrib.auth import get_user_model +from opaque_keys.edx.keys import CourseKey from openedx.core.lib.cache_utils import request_cached from openedx.core.lib.dynamic_partitions_generators import DynamicPartitionGeneratorsPluginManager @@ -44,7 +43,7 @@ def get_all_partitions_for_course(course, active_only=False): return all_partitions -def get_user_partition_groups(course_key: str, user_partitions: list, user: User, +def get_user_partition_groups(course_key: CourseKey, user_partitions: list, user: User, partition_dict_key: str = 'name') -> Dict[str, Group]: """ Collect group ID for each partition in this course for this user.