openedx / openedx/openedx-platform
Fix type annotations in user partitioning code
Nobody has claimed this yet.
- 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-typesormypy path/to/file(s))
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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