fix: incorrect type hints in a few places - #33104
Conversation
|
Thanks for the pull request, @bradenmacdonald! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
| """ 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] |
There was a problem hiding this comment.
The warning here was openedx/core/djangoapps/content_staging/data.py:66: error: Only concrete class can be given where "Type[UsageKey]" is expected [type-abstract]
I don't think it's a valid warning so I've just ignored it.
Agrendalath
left a comment
There was a problem hiding this comment.
👍
- I tested this: checked that this fixes the errors that appeared after applying the changes from the mentioned edx-opaque-keys PR
- I read through the code
- I checked for accessibility issues: n/a
- Includes documentation: n/a
- I made sure any change in configuration variables is reflected in the corresponding client's
configuration-securerepository: n/a
|
@bradenmacdonald 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
|
Thanks @Agrendalath ! |
|
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
Description
As part of my Core Contributor role, I have been working on rolling out type hint declarations and checking in more parts of the codebase. I am about to "turn on" type hints for opaque-keys, but before I can do so I need to fix some minor type errors that exist in
learning_sequences. These weren't detected before because all opaque keys were being type-checked asAny, but once openedx/opaque-keys#259 merges, opaque-keys become distinct types and mypy will catch errors like this.The errors:
Note that in this case these aren't runtime bugs, just errors with the type annotations.
Supporting information
See openedx/opaque-keys#259 , openedx/opaque-keys#256 , #32591 for more context.
Testing instructions
The CI should be sufficient, but if you really want:
mypyfor edx-platform without this change. No errors, but that's because opaque key types are not really being checked.pip install -e .to install the newer type hints into your virtual env.mypyfor edx-platform again - you see the errors I mentioned.mypyone final time - the errors are gone.Deadline
None
Other information
This needs to merge before the corresponding opaque-keys PR.
Private-ref: MNG-3826