@@ -194,3 +194,36 @@ source_modules =
194194forbidden_modules =
195195 openedx_learning.apps
196196allow_indirect_imports = True
197+
198+ [importlinter:contract:4]
199+ name = Low-level apps should not depend on high-level apps
200+ type = layers
201+ layers =
202+ # Layers from high-level to low-level. Imports should only occur from higher to lower.
203+ cms.lib.xblock.upstream_sync | openedx.core.djangoapps.content.search | openedx.core.djangoapps.olx_rest_api
204+ openedx.core.djangoapps.content_libraries
205+ openedx.core.djangoapps.content_staging
206+ openedx.core.djangoapps.xblock
207+ openedx.core.lib.xblock_serializer
208+ openedx.core.djangoapps.content_tagging
209+ ignore_imports =
210+ # Test code can break these layering rules
211+ **.tests.** -> **
212+
213+ # FIXME: the exceptions below are from before we added this import linting rule. Should refactor to eliminate them.
214+ # In particular, the contentstore.helpers module is too big and has too many imports - split it up?
215+
216+ # The CSV export hard-codes support for courses and libraries. Refactor to do something like learning_context.get_children()
217+ openedx.core.djangoapps.content_tagging.helpers.objecttag_export_helpers -> openedx.core.djangoapps.content_libraries.api
218+ # The permissions checking code for tagging requires libraries model data to get all the orgs that a user is using:
219+ openedx.core.djangoapps.content_tagging.utils -> openedx.core.djangoapps.content_libraries.api
220+ # Content staging POST to clipboard API uses libraries APIs. We're working on moving this code to content_libraries
221+ openedx.core.djangoapps.content_staging.views -> openedx.core.djangoapps.content_libraries.api
222+ # content_staging.serializers imports contentstore.helpers which imports contentstore.utils which imports the libraries API.
223+ openedx.core.djangoapps.content_staging.serializers -> cms.djangoapps.contentstore.helpers
224+ # content_libraries.rest_api.libraries imports cms.djangoapps.contentstore.views.course which imports
225+ # contentstore.toggles which imports djangoapps.content.search.api
226+ openedx.core.djangoapps.content_libraries.rest_api.libraries -> cms.djangoapps.contentstore.views.course
227+ # Content libraries imports contentstore.helpers which imports upstream_sync
228+ openedx.core.djangoapps.content_libraries.api.blocks -> cms.djangoapps.contentstore.helpers
229+ openedx.core.djangoapps.content_libraries.api.libraries -> cms.djangoapps.contentstore.helpers
0 commit comments