openedx / openedx/openedx-platform

Fix type annotations in user partitioning code

Open
#31,806 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

code health
Dominant language
Python
Stars
8.2k
Forks
4.4k
Avg merge
6d 18h
Merged PRs (30d)
42

Description

Context

When ./common/lib/xmodule/xmodule was moved to ./xmodule, we gained some increased fidelity on type errors in xmodule-related code, since mypy became able to locate ./xmodule files as local code (before, xmodule was treated as an external library).

One result of this was that a new mypy failure was introduced on this line. In particular, it seems that the enrollment_track_groups dictionary is annotated as a dictionary with str keys, whereas the keys can actually be of several different types, including str, int and NoneType. For the purpose of the common/lib/xmodule refactor PR, we opted to ignore the error, as fixing it would require fixing up several type annotations in https://github.com/openedx/edx-platform/tree/master/xmodule/partitions.

Acceptance Criteria

  • In edx-platform's enrollment_track_partition_groups.py, on the line self.user_group = self.enrollment_track_groups.get(ENROLLMENT_TRACK_PARTITION_ID) # type: ignore, remove the # type: ignore.
  • Fix any resulting cascade of type errors (by running make check-types or mypy path/to/file(s))

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in openedx/core/djangoapps/content/learning_sequences/api/processors/enrollment_track_partition_groups.py at the self.user_group assignment. Remove the type-ignore noted in the acceptance criteria, then run make check-types or mypy on the affected files and fix any resulting cascade of type errors in the enrollment track and xmodule/partitions annotations. Done means the ignore is removed and the type checks pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.