Closed
Conversation
661e2d0 to
950d95a
Compare
950d95a to
041f9d9
Compare
kdmccormick
commented
Dec 10, 2020
|
|
||
| lint-imports: | ||
| pip install -r requirements/edx/importlinter.txt | ||
| lint-imports --config importlinter.cfg |
Member
Author
There was a problem hiding this comment.
we could instead put contracts in .importlinter and obviate the --config argument here, but I liked the GitIHub syntax highlighting that the .cfg file gives us.
Member
Author
|
closed in favor of https://github.com/edx/edx-platform/pull/27011 |
|
Your PR has finished running tests. The following contexts failed:
|
This file contains hidden or 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
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.
This is my first pass at running import-linter on edx-platform.
My current attempt is here: https://github.com/edx/edx-platform/pull/27011
I added a bunch of provisional contracts. Some hold as-is, and others of require a small mountain of exceptions. See
importlinter.cfg; I've annotated it with comments.Notes
My goal here was just to see if I could get the tool verifying contracts at all; I haven't yet dove into the ignore-lists that I built and searched for insights about LMS/Studio decoupling.
I've found that import-linter, as a small but active open source project, leaves some things to be desired (namely, more flexible configuration and more helpful exception reporting). Overall, though, I'm really impressed with the tool and how it reports contract violations, and I'm pleasantly suprised at how quickly it is able to analyze contracts against edx-platform 🎉
I needed to create empty
__init__.pyfiles in a few directories to make the linter happy. I bet that's a limitation that the import-linter maintainers would be open to relaxing, though.A big blocker in realizing the tool's full potential in edx-platform are the locally-installed packages in common/lib (as well as the locally-installed openedx/core/lib/xblock_builtin/xblock_discussion, but that's much smaller and less critical than, say, common/lib/xmodule). The contracts currently in
importlinter.cfgessentially ignore all import chains going through those packages :/Lastly, I haven't checked whether this handles in-function imports (I predict it doesn't). Once pylint amnesty is going, though, it'll be easier to grep forIt looks like import-linter does check function-level imports, which is awesome!wrong-import-positionand check for all those cases.Instructions & example output
Check out this branch, enter an
lms-shell, andmake lint-imports:To see what a broken contract looks like, comment out an
ignore_importsline, for examplecommon.djangoapps.student.models -> lms.djangoapps.courseware.modelswithin[importlinter:contract:cms_lms_forbidden_deep], and re-run.