-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use full names for lms.djangoapps imports #25401
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76a7b72
to
f9b3e49
Compare
7bd0d30
to
f254793
Compare
be6c3bb
to
c0c3a0b
Compare
c0c3a0b
to
42952d4
Compare
jenkins run python |
12a9750
to
af2e820
Compare
cpennington
approved these changes
Nov 2, 2020
af2e820
to
f644572
Compare
f644572
to
7050e60
Compare
Your PR has finished running tests. There were no failures. |
FYI @davidjoy. I expect this to be on prod around 9:45; I'll be keeping a close eye on it. |
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
EdX Release Notice: This PR has been deployed to the production environment. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Part of the
sys.path
modification removal & cleanup, started by https://github.com/edx/edx-platform/pull/24616 . See the ADR for details.This PR fixes all imports of LMS djangoapps to use the preferred style (
import lms.djangoapps.myapp..
) instead of the deprecated short version (import myapp...
). It also un-silences the deprecated-import warnings so that we can see whether any installed packages are using the deprecated imports. Each LMS djangoapp's imports are fixed in their own commit.Related, rename sys_path_hacks to import_shims [MERGED]
Next up, remove sys.path hack for common/djangoapps.
Desired end goal
No sys path hacks warnings on devstack LMS startup.
If possible, having this canary PR without the imports shims get a green build, indicating that all tested old-style imports were fixed.
General approach
I repeated the following approach for each top-level folder in
lms/djangoapps
, notated here as{APPNAME}
:First, replace
from {APPNAME} import {X}
withfrom lms.djangoapps.{APPNAME} import {X}
. Using Sublime Text Find+Replace:Then, search for instances of
import {APPNAME}...
and manually fix them. The manual fixes are required here because
import
withoutfrom
oras
causes the module to imported with its qualified name, so changing the qualified name requires also changing code in the module.Finally, search for references to the old import path by string (patches, INSTALLED_APPS, etc.):
and comb through the output, fixing any references to the old import path. This involves making judgement calls as to what is an import path versus something different (like, a cache key or URL name).
isort
Sorting imports as part of this PR isn't necessary, but it should make the import block much more readable, especially now that many of the names have changed and any previous manual alphabetization efforts have been messed up.
So, I'm going to
include one big isort commit at the endisort everything in a PR after this one.(In the CMS PR, I was able to sort import within cms/ without only some minor
isort:skip
additions, but that folder much smaller and less magic-filled than lms/, common/, and openedx/.)