Commit Graph

75 Commits

Author SHA1 Message Date
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
Feanil Patel
b81a81cbd7 feat: migrate import linter configuration to pyproject.toml
Migrates complete importlinter configuration from setup.cfg, preserving
all 4 contracts, ignore_imports with explanatory comments, and GitHub
issue references.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-03 10:46:16 -05:00
Feanil Patel
bbc12f1b02 feat: migrate pytest configuration to pyproject.toml
Migrates pytest configuration from setup.cfg, preserving all settings
and comments including warning filters and test discovery patterns.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-03 10:46:16 -05:00
Kyle McCormick
a55c1ddabf chore: Switch to new openedx-learning import paths (#38004)
Upgrades openedx-learning from 0.31.0 to 0.32.0,
incorporating a major openedx-learning Python API
restructuring: ca0b3eb
2026-02-13 20:39:05 +00:00
Taylor Payne
7111e8b18c refactor: bring common settings into common module (#37746) 2026-01-09 09:20:59 -07:00
farhan
3c9e1a90de refactor: Move upload/delete transcript int video_config service
This moves edx-platform-specific logic out of the VideoBlock,
in preparation for the VideoBlock extraction:
https://github.com/openedx/edx-platform/issues/36282
2025-12-23 20:44:14 +05:00
Kyle McCormick
91e521ef51 fix: Various fixes to modulestore_migrator (#37711)
For legacy library_content references in courses, this PR:
- **Removes the spurious sync after updating a reference to a migrated
  library**, so that users don't need to "update" their content _after_
  updating their reference, _unless_ there were real content edits that
  happened since they last synced. We do this by correctly associating a
  DraftChangeLogRecord with the ModulestoreBlockSource migration artifact,
  and then comparing that version information before offering a sync.
  (related issue:
  https://github.com/openedx/frontend-app-authoring/issues/2626).
- **Prompts users to update a reference to a migrated library with higher
  priority than prompting them to sync legacy content updates for that
  reference**, so that users don't end up needing to accept legacy content
  updates in order to get a to a point where they can update to V2 content.
- **Ensures the library references in courses always follow the correct
  migration,** as defined by the data `forwarded` fields in the data model,
  which are populated based on the REST API spec and the stated product UI
  requirements.

* For the migration itself, this PR:

- **Allows non-admins to migrate libraries**, fixing:
  https://github.com/openedx/edx-platform/issues/37774
- **When triggered via the UI, ensures the migration uses nice title-based
  target slugs instead of ugly source-hash-based slugs.** We've had this as an
  option for a long time, but preserve_url_slugs defaulted to True instead of
  False in the REST API serializer, so we weren't taking advantage of it.
- **Unifies logic between single-source and bulk migration**. These were
  implement as two separate code paths, with drift in their implementations. In
  particular, the collection update-vs-create-new logic was completely
  different for single-souce vs. bulk.
- **When using the Skip or Update strategies for repeats, it consistently
  follows mappings established by the latest successful migration** rather than
  following mappings across arbitrary previous migrations.
- **We log unexpected exceptions more often**, although there is so much more
  room for improvement here.
- **Adds more validation to the REST API** so that client mistakes more often
  become 400s with validation messages rather than 500s.

For developers, this PR:
- Adds unit tests to the REST API 
- Ensures that all migration business logic now goes through a general-purpose
  Python API.
- Ensures that the data model (specifically `forwarded`, and
  `change_log_record`) is now populated and respected.
- Adds more type annotations.
2025-12-18 23:49:36 +00:00
Irtaza Akram
1945b12769 Autoformat Problem XBlock Source Files for Consistency (1/2) (#37476)
* fix: run formatter black and isort

* fix: linting, pydocstyle, xsslint and security issues
2025-12-05 18:31:45 +05:00
Taylor Payne
d592784b35 refactor: lift shared test settings up to common module (#37714) 2025-12-04 16:50:12 -07:00
Muhammad Farhan Khan
f51343c871 refactor: move transcripts_utils from xmodule to video-config (#37600)
As part of the ongoing effort to deprecate and eventually remove xmodule,
we’ve started gradually migrating the necessary code files from xmodule
to more appropriate locations within the codebase.

Ticket: https://github.com/openedx/public-engineering/issues/445

Also: this tweaks importlinter ignores & add follow-up issue links

Co-authored-by: Kyle McCormick <kyle@axim.org>
2025-11-14 18:26:35 +00:00
Taylor Payne
a98dd3f748 refactor: move explicitly shared settings into new common module 2025-07-21 08:08:34 -04:00
Feanil Patel
88c7cd7bf3 feat!: Remove Legacy Preview Functionality (#36460)
* feat!: Remove all trivial mentions of PREVIEW_LMS_BASE

There are a few more mentions but these are all the ones that don't need
major further followup.

BREAKING CHANGE: The learning MFE now supports preview functionality
natively and it is no longer necessary to use a different domain on the
LMS to render a preview of course content.

See https://github.com/openedx/frontend-app-learning/issues/1455 for
more details.

* feat: Drop the `in_preview_mode` function.

Since we're no longer using a separate domain, that check always
returned false.  Remove it and update any places/tests where it is used.

* feat: Drop courseware_mfe_is_active function.

With the removal of the preview check this function is also a no-op now
so drop calls to it and update the places where it is called to not
change other behavior.

* feat!: Drop redirect to preview from the legacy courseware index.

The CoursewareIndex view is going to be removed eventually but for now
we're focusing on removing the PREVIEW_LMS_BASE setting.  With this
change, if someone tries to load the legacy courseware URL from the
preview domain it will no longer redirect them to the MFE preview.

This is not a problem that will occur for users coming from existing
studio links because those links have already been updated to go
directly to the new urls.

The only way this path could execute is if someone goes directly to the
old Preview URL that they saved off platform somewhere.  eg. If they
bookmarked it for some reason.

BREAKING CHANGE: Saved links (including bookmarks) to the legacy preview
URLs will no longer redirect to the MFE preview URLs.

* test: Drop the set_preview_mode test helper.

This test helper was setting the preview mode for tests by changing the
hostname that was set while tests were running.  This was mostly not
being used to test preview but to run a bunch of legacy courseware tests
while defaulting to the new learning MFE for the courseware.

This commit updates various tests in the `courseware` app to not rely on
the fact that we're in preview to test legacy courseware behavior and
instead directly patches either the `_redirect_to_learning_mfe` function
or uses the `_get_legacy_courseware_url` or both to be able to have the
tests continue to test the legacy coursewary.

This will hopefully make the tests more accuarte even though hopefully
we'll just be removing many of them soon as a part of the legacy
courseware cleanup.

We're just doing the preview removal separately to reduce the number of
things that are changing at once.

* test: Drop the `_get_urls_function`

With the other recent cleanup, this function is no longer being
referenced by anything so we can just drop it.

* test: Test student access to unpublihsed content.

Ensure that students can't get access to unpublished content.
2025-05-14 08:59:11 -04:00
Navin Karkera
1cd73d1b96 feat: support for syncing units from libraries to courses (#36553)
* feat: library unit sync
* feat: create component link only for component xblocks
* feat: container link model
* feat: update downstream api views
* feat: delete extra components in container on sync (not working)
* fix: duplicate definitions of LibraryXBlockMetadata
* test: add a new integration test suite for syncing
* feat: partially implement container+child syncing
* fix: blockserializer wasn't always serializing all HTML block fields
* feat: handle reorder, addition and deletion of components in sync

Updates children components of unit in course based on upstream unit,
deletes removed component, adds new ones and updates order as per
upstream.

* feat: return unit upstreamInfo and disallow edits to units in courses that are sourced from a library (#773)
* feat: Add upstream_info to unit
* feat: disallow edits to units in courses that are sourced from a library (#774)

---------

Co-authored-by: Jillian Vogel <jill@opencraft.com>
Co-authored-by: Rômulo Penido <romulo.penido@gmail.com>

* docs: capitalization of XBlock

Co-authored-by: David Ormsbee <dave@axim.org>

* refactor: (minor) change python property name to reflect type better

* fix: lots of "Tried to inspect a missing...upstream link" warnings

when viewing a unit in Studio

* docs: mention potential REST API for future refactor

* fix: check if upstream actually exists before making unit read-only

* chore: fix camel-case var

* fix: test failure when mocked XBlock doesn't have UpstreamSyncMixin

---------

Co-authored-by: Braden MacDonald <braden@opencraft.com>
Co-authored-by: Chris Chávez <xnpiochv@gmail.com>
Co-authored-by: Jillian Vogel <jill@opencraft.com>
Co-authored-by: Rômulo Penido <romulo.penido@gmail.com>
Co-authored-by: Braden MacDonald <mail@bradenm.com>
Co-authored-by: David Ormsbee <dave@axim.org>
2025-04-24 11:41:47 -07:00
Braden MacDonald
ce00b16be7 test: Enforce application layering using import linter (#36581)
* test: add import linters to promote clean dependencies

* docs: update a few comments / todos
2025-04-23 00:28:30 -04:00
Irtaza Akram
a8a8ae3286 fix: replace pkg_resources with importlib.resources (#36213) 2025-02-13 17:43:07 +05:00
Jesper Hodge
1f43d17b21 Revert "Replace pkg_resources with importlib.resources" (#36208) 2025-02-05 08:51:50 -05:00
Irtaza Akram
acdbff8b4c fix: remove pkg_resources 2025-01-08 16:45:19 +05:00
David Ormsbee
23c4276ec6 test: add data.py to acceptable isolated app imports
Per OEP-49, both api.py and data.py are allowed to be imported into
other apps:

https://open-edx-proposals.readthedocs.io/en/latest/best-practices/oep-0049-django-app-patterns.html#api-py
2024-10-17 13:57:09 -04:00
Feanil Patel
4085066fea Merge pull request #34417 from qasimgulzar/qasim/DEPR/git-issue-34342
[DEPR]: Remove Neo4J Support #34342
2024-05-28 10:25:33 -04:00
David Ormsbee
be03938377 refactor: update to use Learning Core's new public API
This also bumps our openedx-learning dependency to 0.10.0 (the first
version with the new openedx_learning.api package).
2024-05-21 16:05:56 -04:00
qasim.gulzar
48cdbce893 refactor: [DEPR]: Neo4J Support #34342 2024-05-17 18:55:16 +05:00
Zachary Hancock
10805a6a24 feat: remove old proctoring settings url (#33679)
This flag was introduced to gate the rollout of moving the UI component for proctoring settings into the pages and resources view and was never cleaned up. At this point we should always be linking the the new page for proctoring settings.
2023-11-09 08:54:28 -05:00
Daniel Valenzuela
398c84e1bc chore: ignore 'etree' is deprecated
Related issue: https://github.com/openedx/edx-platform/issues/32888
2023-11-01 00:18:40 -03:00
Daniel Valenzuela
9752da2b03 chore: ignore warning from pkg_resources.declare_namespace
Related issue: https://github.com/openedx/edx-platform/issues/33592
2023-11-01 00:18:40 -03:00
Daniel Valenzuela
ef0a9c00af chore: ignore import ABCs from 'collections' warning
related issue: https://github.com/openedx/edx-platform/issues/33584

note: this warning is from a third party library (libsass)
2023-11-01 00:18:40 -03:00
Daniel Valenzuela
d2f427a672 chore: ignore HTTPResponse.getheaders() deprecation warning
related issue: https://github.com/openedx/edx-platform/issues/33584

note: this warning is rased from a third party library (elasticsearch)
2023-11-01 00:18:40 -03:00
Daniel Valenzuela
66c5be8c02 chore: ignore default_app_config warning
related issue: https://github.com/openedx/edx-platform/issues/33572
2023-11-01 00:18:40 -03:00
Muhammad Soban Javed
2732934e74 fix: re-enable Django deprecation warnings (#32277)
* fix: re-enable Django deprecation warnings
---------

Co-authored-by: UsamaSadiq <usama7274@gmail.com>
2023-08-07 22:08:00 +05:00
connorhaugh
00b1ce28b9 feat: add library copy management command (#32598)
This PR introduces the "copy" management command, which copies v1 libraries into v2 libraries.
2023-07-10 15:45:18 -04:00
connorhaugh
57fd22ba58 feat: ignore v2 xblocks in independence contract (#32602)
* feat: ignore v2 xblocks in independance contract

* docs: add documentation as to failure point
2023-06-29 16:08:14 -04:00
ruzniaievdm
96b8ba5d6a feat: Create DRF for course settings and course details views out of current Django views (#32397) 2023-06-08 11:07:29 -04:00
Braden MacDonald
8ee1f66ffb feat: Paste Components (OLX) into any Unit in Studio (#31969)
* feat: Implement paste button

* chore: improve docs and add tests for python API

* fix: drive-by fix to use a better API for comparing XML

* feat: track which XBlock something was copied from

* feat: add tests

* feat: enable import linter so content_staging's public API is respected

* fix: error seen when trying to paste drag-and-drop-v2 blocks

* fix: use strip_text=True consistently for XML comparisons

* refactor: rename get_user_clipboard_status to get_user_clipboard

* feat: Better error reporting when pasting in Studio

* chore: convert new test suite to pytest assertions

* refactor: push READY status check into the API per review suggestion

* fix: use strip_text=True consistently for XML comparisons

* fix: store "copied_from_block" as a string to avoid Reference field issues

* fix: minor lint error

* refactor: move data types to data.py per OEP-49
2023-04-27 09:58:04 -07:00
Braden MacDonald
dd927c7fee chore: consolidate two different implementations for serializing XBlocks 2023-04-24 12:16:42 -07:00
Braden MacDonald
626f11f608 test: Import linter: optionally enforce usage of a package's public API (#31903)
* test: warn about dependencies from cms->openedx->lms and vice versa

* test: warn about importing from package's internal implementation code

* chore: Update some imports to use public APIs only

* chore: Update 'bookmarks' app to have stricter public API

* fix: we are sharing 'adapters' from olx_rest_api to content_staging
2023-04-20 11:34:51 -07:00
0x29a
d338f00e39 refactor: rename module (or item) -> block within cms 2023-01-30 18:15:23 +01:00
Muhammad Umar Khan
9c279444df build: add import linter check (#31062)
* build: add import linter check
2022-12-07 12:07:09 +05:00
Kyle McCormick
25df9ca420 refactor: make safe_lxml an ordinary folder in openedx/core/lib (#25689) 2022-05-24 15:35:23 +05:00
Ned Batchelder
66eae81add docs: comments about how pytest finds settings (#29623)
It took a while for me to understand why my setup.cfg setting was only
applying to some tests.  Hopefully these comments will save someone else
some confusion.
2021-12-21 10:47:59 -05:00
Ned Batchelder
e39f9c503a build: suppress Django deprecation warnings (#29528)
Suppress them both in tests (via setup.py and pytest.ini)
and in management command & application runs
(via logsettings.py).

Developers aren't looking at these warnings; they'll be dealt with in a
formal process for upgrading Django.  Suppress them for now so that
important information isn't lost in the noise.
2021-12-15 10:45:12 -05:00
Ned Batchelder
d67a16452f Ensure setup.cfg is only ASCII. CRI-169
I don't understand why this file needs to be ASCII, or why it was only a
problem recently for one installer, since this has been in this file
since 2014.  But CRI-169 has a stack trace, and it's easy enough to make
the file ASCII.
2020-05-01 16:00:53 -04:00
Jeremy Bowman
59768e7498 Fix more deprecation warnings (#23061) 2020-02-10 13:17:25 -05:00
Manjinder Singh
6c69b6d435 Adding code to output pytest warnings. (#22570)
* Added pytest-json-report plugin
	- modifying app-opts in setup.cfg
	- adding hook to all conftest.py files in repo
	- setting report to be saved to test_root/log/warnings.json
	- Writing custom logic to save json report to avoid overwrite if pytest called twice
This was created to allow us to easily parse through test warnings in jenkins
2020-01-02 10:01:52 -05:00
Calen Pennington
b4fe3474e7 Fix/ignore errors caused by a pycodestyle upgrade 2018-10-31 12:34:50 -04:00
Jeremy Bowman
9477ad23d1 TE-2528 Upgrade testing dependencies 2018-04-25 16:37:29 -04:00
Jeremy Bowman
28d291dce7 TE-2527 Move test and dev dependencies out of base.in 2018-04-18 14:44:31 -04:00
Jeremy Bowman
11e134c552 PLAT-1916 Ignore existing usage of deprecated field_data 2018-02-02 16:12:00 -05:00
Jeremy Bowman
7d436a18ee PLAT-1858 Better capture of deprecation warnings 2018-01-12 18:04:32 -05:00
Jeremy Bowman
1dbdee9c54 Revert "PLAT-1858 Better capture of deprecation warnings" 2017-12-18 21:18:02 -05:00
Jeremy Bowman
b26fe5fd24 PLAT-1858 Better capture of deprecation warnings 2017-12-18 14:59:05 -05:00
Ned Batchelder
8b02ce8394 Skip safe_lxml/etree.py in future isorts 2017-12-12 19:39:35 -05:00