Files
edx-platform/pyproject.toml
Feanil Patel 467495cb22 feanil/pycodestyle to ruff (#38076)
* feat: add ruff and configure it to match current pycodestyle rules

Adds ruff to testing requirements and configures it in pyproject.toml
to enforce the same E/W rules that pycodestyle 2.8.x was enforcing.
Two additional rules (E714, E721) that pycodestyle 2.8.x did not enforce
are explicitly ignored for now and can be cleaned up in a follow-up.

Part of the migration from pycodestyle → ruff.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: add ruff Makefile target

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: add ruff to quality CI workflow alongside pycodestyle

Runs ruff alongside pycodestyle so we can validate parity before
removing pycodestyle in the next commit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: remove pycodestyle, replaced by ruff

- Remove pycodestyle from requirements
- Remove pycodestyle version constraint (pinned to <2.9.0 due to a
  false positive E275 bug that is no longer relevant)
- Remove [pycodestyle] config from setup.cfg (config now lives in
  pyproject.toml under [tool.ruff])
- Remove pycodestyle Makefile target
- Remove make pycodestyle from quality CI workflow

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* style: Apply suggestions from code review

Remove unnecessary ignores.

Co-authored-by: Braden MacDonald <braden@opencraft.com>

* style: Fix a style isusue and remove ignores.

Most of these ignores are unnecessary as we're passing them now and we
want to check them in the future. E714 only had one fixable violation so
we just fixed it.

* style: Update ruff config and workflows

* Update the call to `ruff` so that it outputs in a github friendly
manner.

* Remove ruff exclusions that are already covered by .gitignore which
  ruff respects.

* chore: Recompile requirements.

Update the requirements to drop pycodestyle and add ruff.

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Braden MacDonald <braden@opencraft.com>
2026-03-04 17:33:06 +00:00

420 lines
24 KiB
TOML

[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
[project]
name = "openedx-platform"
version = "0.13"
requires-python = ">=3.11"
dependencies = ["setuptools"]
[tool.setuptools]
packages = ["cms", "common", "lms", "openedx", "xmodule"]
[tool.setuptools.package-data]
xmodule = ["js/module/*"]
[project.entry-points."xblock.v1"]
about = "xmodule.html_block:AboutBlock"
book = "xmodule.template_block:TranslateCustomTagBlock"
annotatable = "xmodule.annotatable_block:AnnotatableBlock"
chapter = "xmodule.seq_block:SectionBlock"
conditional = "xmodule.conditional_block:ConditionalBlock"
course = "xmodule.course_block:CourseBlock"
course_info = "xmodule.html_block:CourseInfoBlock"
customtag = "xmodule.template_block:CustomTagBlock"
custom_tag_template = "xmodule.template_block:CustomTagTemplateBlock"
discuss = "xmodule.template_block:TranslateCustomTagBlock"
discussion = "xmodule.discussion_block:DiscussionXBlock"
error = "xmodule.error_block:ErrorBlock"
hidden = "xmodule.hidden_block:HiddenBlock"
html = "xmodule.html_block:HtmlBlock"
itembank = "xmodule.item_bank_block:ItemBankBlock"
image = "xmodule.template_block:TranslateCustomTagBlock"
library = "xmodule.library_root_xblock:LibraryRoot"
library_content = "xmodule.library_content_block:LegacyLibraryContentBlock"
lti = "xmodule.lti_block:LTIBlock"
poll_question = "xmodule.poll_block:PollBlock"
problem = "xmodule.capa_block:ProblemBlock"
randomize = "xmodule.randomize_block:RandomizeBlock"
sequential = "xmodule.seq_block:SequenceBlock"
slides = "xmodule.template_block:TranslateCustomTagBlock"
split_test = "xmodule.split_test_block:SplitTestBlock"
static_tab = "xmodule.html_block:StaticTabBlock"
unit = "xmodule.unit_block:UnitBlock"
vertical = "xmodule.vertical_block:VerticalBlock"
video = "xmodule.video_block:VideoBlock"
videoalpha = "xmodule.video_block:VideoBlock"
videodev = "xmodule.template_block:TranslateCustomTagBlock"
word_cloud = "xmodule.word_cloud_block:WordCloudBlock"
wrapper = "xmodule.wrapper_block:WrapperBlock"
[project.entry-points."xblock_asides.v1"]
tagging_aside = "cms.lib.xblock.tagging:StructuredTagsAside"
[project.entry-points."openedx.course_tab"]
ccx = "lms.djangoapps.ccx.plugins:CcxCourseTab"
courseware = "lms.djangoapps.courseware.tabs:CoursewareTab"
dates = "lms.djangoapps.courseware.tabs:DatesTab"
discussion = "lms.djangoapps.discussion.plugins:DiscussionTab"
edxnotes = "lms.djangoapps.edxnotes.plugins:EdxNotesTab"
external_discussion = "lms.djangoapps.courseware.tabs:ExternalDiscussionCourseTab"
external_link = "lms.djangoapps.courseware.tabs:ExternalLinkCourseTab"
html_textbooks = "lms.djangoapps.courseware.tabs:HtmlTextbookTabs"
instructor = "lms.djangoapps.instructor.views.instructor_dashboard:InstructorDashboardTab"
lti_discussion = "openedx.features.lti_course_tab.tab:DiscussionLtiCourseTab"
lti_live = "openedx.core.djangoapps.course_live.tab:CourseLiveTab"
lti_tab = "openedx.features.lti_course_tab.tab:LtiCourseTab"
pdf_textbooks = "lms.djangoapps.courseware.tabs:PDFTextbookTabs"
progress = "lms.djangoapps.courseware.tabs:ProgressTab"
static_tab = "xmodule.tabs:StaticTab"
syllabus = "lms.djangoapps.courseware.tabs:SyllabusTab"
teams = "lms.djangoapps.teams.plugins:TeamsTab"
textbooks = "lms.djangoapps.courseware.tabs:TextbookTabs"
wiki = "lms.djangoapps.course_wiki.tab:WikiTab"
[project.entry-points."openedx.course_app"]
calculator = "lms.djangoapps.courseware.plugins:CalculatorCourseApp"
custom_pages = "lms.djangoapps.courseware.plugins:CustomPagesCourseApp"
dates = "lms.djangoapps.courseware.plugins:DatesCourseApp"
discussion = "openedx.core.djangoapps.discussions.plugins:DiscussionCourseApp"
edxnotes = "lms.djangoapps.edxnotes.plugins:EdxNotesCourseApp"
live = "openedx.core.djangoapps.course_live.plugins:LiveCourseApp"
ora_settings = "lms.djangoapps.courseware.plugins:ORASettingsApp"
proctoring = "lms.djangoapps.courseware.plugins:ProctoringCourseApp"
progress = "lms.djangoapps.courseware.plugins:ProgressCourseApp"
teams = "lms.djangoapps.teams.plugins:TeamsCourseApp"
textbooks = "lms.djangoapps.courseware.plugins:TextbooksCourseApp"
wiki = "lms.djangoapps.course_wiki.plugins.course_app:WikiCourseApp"
[project.entry-points."openedx.course_tool"]
calendar_sync_toggle = "openedx.features.calendar_sync.plugins:CalendarSyncToggleTool"
course_bookmarks = "openedx.features.course_bookmarks.plugins:CourseBookmarksTool"
course_updates = "openedx.features.course_experience.plugins:CourseUpdatesTool"
financial_assistance = "lms.djangoapps.courseware.course_tools:FinancialAssistanceTool"
[project.entry-points."lms.djangoapp"]
ace_common = "openedx.core.djangoapps.ace_common.apps:AceCommonConfig"
content_libraries = "openedx.core.djangoapps.content_libraries.apps:ContentLibrariesConfig"
course_apps = "openedx.core.djangoapps.course_apps.apps:CourseAppsConfig"
course_live = "openedx.core.djangoapps.course_live.apps:CourseLiveConfig"
courseware_api = "openedx.core.djangoapps.courseware_api.apps:CoursewareAPIConfig"
credentials = "openedx.core.djangoapps.credentials.apps:CredentialsConfig"
discussion = "lms.djangoapps.discussion.apps:DiscussionConfig"
discussions = "openedx.core.djangoapps.discussions.apps:DiscussionsConfig"
grades = "lms.djangoapps.grades.apps:GradesConfig"
plugins = "openedx.core.djangoapps.plugins.apps:PluginsConfig"
theming = "openedx.core.djangoapps.theming.apps:ThemingConfig"
bookmarks = "openedx.core.djangoapps.bookmarks.apps:BookmarksConfig"
zendesk_proxy = "openedx.core.djangoapps.zendesk_proxy.apps:ZendeskProxyConfig"
instructor = "lms.djangoapps.instructor.apps:InstructorConfig"
password_policy = "openedx.core.djangoapps.password_policy.apps:PasswordPolicyConfig"
user_authn = "openedx.core.djangoapps.user_authn.apps:UserAuthnConfig"
program_enrollments = "lms.djangoapps.program_enrollments.apps:ProgramEnrollmentsConfig"
[project.entry-points."cms.djangoapp"]
ace_common = "openedx.core.djangoapps.ace_common.apps:AceCommonConfig"
bookmarks = "openedx.core.djangoapps.bookmarks.apps:BookmarksConfig"
course_live = "openedx.core.djangoapps.course_live.apps:CourseLiveConfig"
content_libraries = "openedx.core.djangoapps.content_libraries.apps:ContentLibrariesConfig"
content_staging = "openedx.core.djangoapps.content_staging.apps:ContentStagingAppConfig"
course_apps = "openedx.core.djangoapps.course_apps.apps:CourseAppsConfig"
# Importing an LMS app into the Studio process is not a good practice.
# We're ignoring this for Discussions here because its placement in LMS
# is a historical artifact. The eventual goal is to consolidate the multiple
# discussions-related Django apps and either put them in the openedx/ dir,
# or in another repo entirely.
discussion = "lms.djangoapps.discussion.apps:DiscussionConfig"
discussions = "openedx.core.djangoapps.discussions.apps:DiscussionsConfig"
instructor = "lms.djangoapps.instructor.apps:InstructorConfig"
olx_rest_api = "openedx.core.djangoapps.olx_rest_api.apps:OlxRestApiAppConfig"
password_policy = "openedx.core.djangoapps.password_policy.apps:PasswordPolicyConfig"
plugins = "openedx.core.djangoapps.plugins.apps:PluginsConfig"
theming = "openedx.core.djangoapps.theming.apps:ThemingConfig"
user_authn = "openedx.core.djangoapps.user_authn.apps:UserAuthnConfig"
zendesk_proxy = "openedx.core.djangoapps.zendesk_proxy.apps:ZendeskProxyConfig"
[project.entry-points."openedx.block_structure_transformer"]
library_content = "lms.djangoapps.course_blocks.transformers.library_content:ContentLibraryTransformer"
library_content_randomize = "lms.djangoapps.course_blocks.transformers.library_content:ContentLibraryOrderTransformer"
split_test = "lms.djangoapps.course_blocks.transformers.split_test:SplitTestTransformer"
start_date = "lms.djangoapps.course_blocks.transformers.start_date:StartDateTransformer"
user_partitions = "lms.djangoapps.course_blocks.transformers.user_partitions:UserPartitionTransformer"
visibility = "lms.djangoapps.course_blocks.transformers.visibility:VisibilityTransformer"
hidden_content = "lms.djangoapps.course_blocks.transformers.hidden_content:HiddenContentTransformer"
course_blocks_api = "lms.djangoapps.course_api.blocks.transformers.blocks_api:BlocksAPITransformer"
milestones = "lms.djangoapps.course_api.blocks.transformers.milestones:MilestonesAndSpecialExamsTransformer"
grades = "lms.djangoapps.grades.transformer:GradesTransformer"
completion = "lms.djangoapps.course_api.blocks.transformers.block_completion:BlockCompletionTransformer"
load_override_data = "lms.djangoapps.course_blocks.transformers.load_override_data:OverrideDataTransformer"
content_type_gate = "openedx.features.content_type_gating.block_transformers:ContentTypeGateTransformer"
access_denied_message_filter = "lms.djangoapps.course_blocks.transformers.access_denied_filter:AccessDeniedMessageFilterTransformer"
open_assessment_transformer = "lms.djangoapps.courseware.transformers:OpenAssessmentDateTransformer"
effort_estimation = "openedx.features.effort_estimation.api:EffortEstimationTransformer"
discussions_link = "openedx.core.djangoapps.discussions.transformers:DiscussionsTopicLinkTransformer"
[project.entry-points."openedx.user_partition_scheme"]
cohort = "openedx.core.djangoapps.course_groups.partition_scheme:CohortPartitionScheme"
content_type_gate = "openedx.features.content_type_gating.partitions:ContentTypeGatingPartitionScheme"
enrollment_track = "openedx.core.djangoapps.verified_track_content.partition_scheme:EnrollmentTrackPartitionScheme"
random = "openedx.core.djangoapps.user_api.partition_schemes:RandomUserPartitionScheme"
team = "lms.djangoapps.teams.team_partition_scheme:TeamPartitionScheme"
verification = "openedx.core.djangoapps.user_api.partition_schemes:ReturnGroup1PartitionScheme"
[project.entry-points."openedx.ace.policy"]
bulk_email_optout = "lms.djangoapps.bulk_email.policies:CourseEmailOptout"
course_push_notification_optout = "openedx.core.djangoapps.notifications.policies:CoursePushNotificationOptout"
disabled_user_optout = "openedx.core.djangoapps.ace_common.policies:DisableUserOptout"
[project.entry-points."openedx.call_to_action"]
personalized_learner_schedules = "openedx.features.personalized_learner_schedules.call_to_action:PersonalizedLearnerScheduleCallToAction"
[project.entry-points."openedx.learning_context"]
lib = "openedx.core.djangoapps.content_libraries.library_context:LibraryContextImpl"
[project.entry-points."openedx.dynamic_partition_generator"]
content_type_gating = "openedx.features.content_type_gating.partitions:create_content_gating_partition"
enrollment_track = "xmodule.partitions.enrollment_track_partition_generator:create_enrollment_track_partition"
team = "openedx.core.lib.teams_config:create_team_set_partition"
[project.entry-points.console_scripts]
xmodule_assets = "xmodule.static_content:main"
[tool.pytest.ini_options]
# Note: The first file of settings found is used, there is no combining, so
# this file is only used for tests that don't find a pytest.ini file first.
# Details at https://docs.pytest.org/en/latest/reference/customize.html
DJANGO_SETTINGS_MODULE = "lms.envs.test"
addopts = "--nomigrations --reuse-db --durations=20 --json-report --json-report-omit keywords streams collectors log traceback tests --json-report-file=none"
# Enable default handling for all warnings, including those that are ignored by default;
# but hide rate-limit warnings (because we deliberately don't throttle test user logins)
# and field_data deprecation warnings (because fixing them requires a major low-priority refactoring)
filterwarnings = [
"default",
"ignore:No request passed to the backend, unable to rate-limit:UserWarning",
"ignore::xblock.exceptions.FieldDataDeprecationWarning",
# Remove default_app_config warning after updating Django to 4.2
"ignore:.*You can remove default_app_config.*:PendingDeprecationWarning",
"ignore:Instead access HTTPResponse.headers directly.*:DeprecationWarning:elasticsearch",
# ABC deprecation Warning comes from libsass
"ignore:Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated.*:DeprecationWarning:sass",
"ignore:'etree' is deprecated. Use 'xml.etree.ElementTree' instead.:DeprecationWarning:wiki",
]
junit_family = "xunit2"
norecursedirs = ". .* *.egg build conf dist node_modules test_root cms/envs lms/envs openedx/envs"
python_classes = []
python_files = ["tests.py", "test_*.py", "tests_*.py", "*_tests.py", "__init__.py"]
[tool.ruff]
line-length = 120
exclude = [
"migrations",
"test_root/staticfiles",
]
[tool.ruff.lint]
select = ["E", "W"]
ignore = [
"E402", # module level import not at top of file
"E501", # line too long (pylint enforces this at 120 chars while ignoring trailing comments)
"E722", # do not use bare 'except'
"E731", # do not assign a lambda expression
"E741", # ambiguous variable name. TODO: fix the ~9 issues and re-enable this.
# The rules below were added in pycodestyle 2.9.x but we were pinned to 2.8.x,
# so they represent new findings. Keeping them ignored here to make this an
# equivalent swap; they can be cleaned up in a follow-up.
"E721", # use `isinstance()` for type comparisons
]
[tool.isort]
indent = " "
line_length = 120
multi_line_output = 3
skip = ["envs", "migrations"]
[tool.importlinter]
root_packages = ["lms", "cms", "openedx", "openedx_content"]
include_external_packages = true
# Our custom contract which checks that we're only importing from 'api.py'
# for participating packages.
contract_types = [
"isolated_apps: openedx.testing.importlinter.isolated_apps_contract.IsolatedAppsContract",
]
[[tool.importlinter.contracts]]
name = "lms and cms are independent"
type = "independence"
modules = ["lms", "cms"]
ignore_imports = [
# lms side imports that we are ignoring for now
"lms.djangoapps.course_home_api.outline.tests.test_view -> cms.djangoapps.contentstore.outlines",
"lms.djangoapps.course_home_api.tests.utils -> cms.djangoapps.contentstore.outlines",
# lms.djangoapps.instructor.tests.test_api & lms.djangoapps.instructor.tests.test_tools
# -> openedx.core.djangoapps.course_date_signals.handlers
# -> cms.djangoapps.contentstore.config.waffle
"openedx.core.djangoapps.course_date_signals.handlers -> cms.djangoapps.contentstore.config.waffle",
# cms side imports that we are ignoring for now
"cms.djangoapps.contentstore.views.tests.test_block -> lms.djangoapps.lms_xblock.mixin",
"cms.djangoapps.contentstore.signals.handlers -> lms.djangoapps.grades.api",
"cms.djangoapps.contentstore.course_group_config -> lms.lib.utils",
"cms.djangoapps.contentstore.views.preview -> lms.djangoapps.lms_xblock.field_data",
# cms.envs.common
# -> openedx.envs.common
# -> lms.djangoapps.lms_xblock.mixin
"openedx.envs.common -> lms.djangoapps.lms_xblock.mixin",
# cms.djangoapps.contentstore.views.tests.test_group_configurations
# -> openedx.features.content_type_gating.helpers
# -> lms.djangoapps.courseware.masquerade
"openedx.features.content_type_gating.helpers -> lms.djangoapps.courseware.masquerade",
# cms.djangoapps.contentstore.utils
# -> openedx.core.djangoapps.django_comment_common.models
# -> openedx.core.djangoapps.course_groups.cohorts
# -> lms.djangoapps.courseware.courses
"openedx.core.djangoapps.course_groups.cohorts -> lms.djangoapps.courseware.courses",
# cms.djangoapps.contentstore.[various]
# -> openedx.features.content_type_gating.partitions
# -> lms.djangoapps.commerce.utils
"openedx.features.content_type_gating.partitions -> lms.djangoapps.commerce.utils",
# cms.djangoapps.contentstore.course_group_config
# -> openedx.core.djangoapps.course_groups.partition_scheme
# -> lms.djangoapps.courseware.masquerade
"openedx.core.djangoapps.course_groups.partition_scheme -> lms.djangoapps.courseware.masquerade",
# cms.djangoapps.export_course_metadata.tasks
# -> openedx.core.djangoapps.schedules.content_highlights
# -> lms.djangoapps.courseware.block_render & lms.djangoapps.courseware.model_data
"openedx.core.djangoapps.content_libraries.* -> lms.djangoapps.*.*",
# cms.djangoapps.contentstore.tasks -> openedx.core.djangoapps.content_libraries.[various]
# -> lms.djangoapps.grades.api
"openedx.core.djangoapps.xblock.*.* -> lms.djangoapps.*.*",
# cms.djangoapps.contentstore.tasks -> openedx.core.djangoapps.content_libraries.[various] -> openedx.core.djangoapps.xblock.[various]
# -> lms.djangoapps.courseware & lms.djangoapps.courseware.grades
"openedx.core.djangoapps.schedules.content_highlights -> lms.djangoapps.courseware.*",
# cms.djangoapps.contentstore.[various]
# -> openedx.core.lib.gating.api
# -> lms.djangoapps.course_blocks.api & lms.djangoapps.courseware.access & lms.djangoapps.grades.api
"openedx.core.lib.gating.api -> lms.djangoapps.*.*",
# cms.djangoapps.contentstore.[various]
# -> openedx.features.content_type_gating.partitions
# -> openedx.features.discounts.utils
# -> lms.djangoapps.courseware.utils & lms.djangoapps.experiments.models
"openedx.features.discounts.utils -> lms.djangoapps.courseware.utils",
"openedx.features.discounts.utils -> lms.djangoapps.experiments.models",
# cms.djangoapps.contentstore.signals.handlers
# -> openedx.core.djangoapps.discussions.tasks
# -> openedx.core.djangoapps.discussions.utils
# -> lms.djangoapps.courseware.access
"openedx.core.djangoapps.discussions.utils -> lms.djangoapps.courseware.access",
# cms.djangoapps.contentstore.[various]
# -> openedx.features.content_type_gating.partitions
# -> openedx.features.discounts.utils
# -> openedx.features.discounts.applicability
# -> lms.djangoapps.courseware.toggles
# & lms.djangoapps.courseware.utils
# & lms.djangoapps.experiments.models
# & lms.djangoapps.experiments.stable_bucketing
"openedx.features.discounts.applicability -> lms.djangoapps.courseware.*",
"openedx.features.discounts.applicability -> lms.djangoapps.experiments.*",
# cms.djangoapps.contentstore.[various]
# -> openedx.core.djangoapps.content.learning_sequences.api
# -> openedx.core.djangoapps.content.learning_sequences.api.outlines
# -> openedx.core.djangoapps.content.learning_sequences.api.permissions
# -> lms.djangoapps.courseware.access
"openedx.core.djangoapps.content.learning_sequences.api.permissions -> lms.djangoapps.courseware.access",
# cms.djangoapps.contentstore.[various]
# -> openedx.features.content_type_gating.partitions
# -> openedx.features.discounts.utils
# -> openedx.features.discounts.applicability
# -> openedx.features.enterprise_support.utils
"openedx.features.enterprise_support.utils -> lms.djangoapps.branding.api",
"cms.djangoapps.contentstore.rest_api.v1.views.settings -> lms.djangoapps.certificates.api",
# We are ignoring this existing import until we can refactor contenstore/helpers.
# https://github.com/openedx/edx-platform/issues/37637
"openedx.core.djangoapps.content_libraries.api.libraries -> cms.djangoapps.contentstore.helpers",
"openedx.core.djangoapps.content_libraries.api.blocks -> cms.djangoapps.contentstore.helpers",
"openedx.core.djangoapps.content_staging.serializers -> cms.djangoapps.contentstore.helpers",
# These imports will become OK once we move content_libraries into CMS
# https://github.com/openedx/edx-platform/issues/33428
"openedx.core.djangoapps.content_libraries.permissions -> cms.djangoapps.course_creators.views",
"openedx.core.djangoapps.content_libraries.tasks -> cms.djangoapps.contentstore.storage",
# Outstanding arch issue: course_overviews is tangled up with LMS
# https://github.com/openedx/edx-platform/issues/37658
"openedx.core.djangoapps.content.course_overviews.models -> lms.djangoapps.**",
# Outstanding arch issue: content_highlights uses courseware block_render
# https://github.com/openedx/edx-platform/issues/37659
"openedx.core.djangoapps.schedules.content_highlights -> lms.djangoapps.courseware.block_render",
]
[[tool.importlinter.contracts]]
name = "Do not depend on non-public API of isolated apps."
type = "isolated_apps"
isolated_apps = [
"cms.djangoapps.modulestore_migrator",
"openedx.core.djangoapps.agreements",
"openedx.core.djangoapps.bookmarks",
"openedx.core.djangoapps.content_libraries",
"openedx.core.djangoapps.content_staging",
"openedx.core.djangoapps.olx_rest_api",
"openedx.core.djangoapps.xblock",
"openedx.core.lib.xblock_serializer",
]
allowed_modules = [
# Only imports from api.py and data.py are allowed elsewhere in the code
# See https://open-edx-proposals.readthedocs.io/en/latest/best-practices/oep-0049-django-app-patterns.html#api-py
"api",
"data",
"tests",
]
[[tool.importlinter.contracts]]
name = "Do not directly import internals of openedx_content (only import from openedx_content.api)."
type = "forbidden"
source_modules = ["cms", "lms", "openedx", "common", "xmodule"]
forbidden_modules = ["openedx_content.applets", "openedx_content.backcompat"]
allow_indirect_imports = true
[[tool.importlinter.contracts]]
name = "Low-level apps should not depend on high-level apps"
type = "layers"
layers = [
# Layers from high-level to low-level. Imports should only occur from higher to lower.
"cms.lib.xblock.upstream_sync | openedx.core.djangoapps.content.search | openedx.core.djangoapps.olx_rest_api",
"openedx.core.djangoapps.content_libraries",
"openedx.core.djangoapps.content_staging",
"openedx.core.djangoapps.xblock",
"openedx.core.lib.xblock_serializer",
"openedx.core.djangoapps.content_tagging",
]
ignore_imports = [
# Test code can break these layering rules
"**.tests.** -> **",
# FIXME: the exceptions below are from before we added this import linting rule. Should refactor to eliminate them.
# In particular, the contentstore.helpers module is too big and has too many imports
# See https://github.com/openedx/edx-platform/issues/37637
# The CSV export hard-codes support for courses and libraries. Refactor to do something like learning_context.get_children()
"openedx.core.djangoapps.content_tagging.helpers.objecttag_export_helpers -> openedx.core.djangoapps.content_libraries.api",
# The permissions checking code for tagging requires libraries model data to get all the orgs that a user is using:
"openedx.core.djangoapps.content_tagging.utils -> openedx.core.djangoapps.content_libraries.api",
# Content staging POST to clipboard API uses libraries APIs. We're working on moving this code to content_libraries
"openedx.core.djangoapps.content_staging.views -> openedx.core.djangoapps.content_libraries.api",
# content_staging.serializers imports contentstore.helpers which imports contentstore.utils which imports the libraries API.
"openedx.core.djangoapps.content_staging.serializers -> cms.djangoapps.contentstore.helpers",
# content_libraries.rest_api.libraries imports cms.djangoapps.contentstore.views.course which imports
# contentstore.toggles which imports djangoapps.content.search.api
"openedx.core.djangoapps.content_libraries.rest_api.libraries -> cms.djangoapps.contentstore.views.course",
# Content libraries imports contentstore.helpers which imports upstream_sync
"openedx.core.djangoapps.content_libraries.api.blocks -> cms.djangoapps.contentstore.helpers",
"openedx.core.djangoapps.content_libraries.api.libraries -> cms.djangoapps.contentstore.helpers",
# Outstanding arch issue: course_overviews is tangled up with LMS
# https://github.com/openedx/edx-platform/issues/37658
"openedx.core.djangoapps.content.course_overviews.models -> lms.djangoapps.**",
# Outstanding arch issue: content_highlights uses courseware block_render
# https://github.com/openedx/edx-platform/issues/37659
"openedx.core.djangoapps.schedules.content_highlights -> lms.djangoapps.courseware.block_render",
# This import happens only because grading signals are defined in LMS rather than openedx-events
# https://github.com/openedx/edx-platform/issues/37660
"openedx.core.djangoapps.xblock.runtime.runtime -> lms.djangoapps.grades.api",
# These imports will become OK once we worked on the following issue:
# https://github.com/openedx/edx-platform/issues/33428
"openedx.core.djangoapps.video_config.services -> openedx.core.djangoapps.content_libraries.api",
]