Skip to content

Conversation

@BryanttV
Copy link
Contributor

Description

This PR replaces pycodestyle, isort and pylint (partially).

Testing instructions

You can run make quality in your local or see the PR checks.

Supporting information

Deadline

None

Other information

pycodestyle and isort can be completely replaced with ruff but not with pylint. More information in Ruff and Pylint comparison

  • Ruff doesn't currently support custom rules, Pylint does. Open edX has some custom rules that couldn't be implemented for now.

Below is the detail of each rule. Here is an issue with the pylint rules implemented in Ruff (astral-sh/ruff#970) In summary:

  • Total: 173 rules
  • Implemented: 82 rules (47.4%)
  • NOT Implemented (❌ + custom Open edX): 74 rules (42.8%)
  • Others: 17 rules (9.8%)
Rules

Enabled Rules

Implemented

  • line-too-long (E501)
  • assert-on-tuple (F631)
  • assigning-non-slot (PLE0237)
  • bad-format-character (PLE1300)
  • bad-staticmethod-argument (PLW0211)
  • bad-str-strip-call (PLE1310)
  • bad-format-string (F521)
  • bad-open-mode (PLW1501)
  • binary-op-exception (PLW0711)
  • cell-var-from-loop (B023)
  • continue-in-finally (PLE0116)
  • dangerous-default-value (B006)
  • duplicate-bases (PLE0241)
  • duplicate-except (B014)
  • duplicate-key (F601)
  • expression-not-assigned (B018)
  • format-combined-specification (F525)
  • format-needs-mapping (F502)
  • function-redefined (F811)
  • import-self (PLW0406)
  • init-is-generator (PLE0100)
  • invalid-all-object (PLE0604)
  • invalid-format-index (F522)
  • invalid-length-returned (PLE0303)
  • logging-too-few-args (PLE1206)
  • logging-too-many-args (PL1205)
  • lost-exception (B012)
  • misplaced-bare-raise (PLE704)
  • misplaced-future (F404)
  • missing-format-argument-key (F524)
  • missing-format-string-key (F524)
  • no-self-argument (N805)
  • nonexistent-operator (B002)
  • not-in-loop (F701, F702)
  • pointless-statement (B018)
  • redefined-builtin (A001)
  • repeated-keyword (PLE1132)
  • return-in-init (PLE0101)
  • return-outside-function (F706)
  • syntax-error (E999) -> Always enabled
  • too-few-format-args (F524)
  • too-many-format-args (F522)
  • truncated-format-string (F501)
  • undefined-all-variable (F822)
  • undefined-variable (F821)
  • unexpected-special-method-signature (PLE0302)
  • unused-format-string-argument (F507)
  • unused-format-string-key (F504)
  • used-before-assignment (F821)
  • yield-outside-function (F704)
  • missing-docstring -> Renamed to:
    • missing-module-docstring (D100) Enabled in pydocstyle
    • missing-class-docstring (D101) Disabled in pydocstyle
    • missing-function-docstring (D103) Enabled in pydocstyle
  • empty-docstring (D419)
  • unused-argument (ARG001)
  • unused-import (F401)
  • unused-variable (F841)
  • eval-used (S307)
  • exec-used (S102)
  • bad-classmethod-argument (N804)
  • bare-except (E722)
  • broad-except -> Renamed to broad-exception-caught (BLE001)
  • consider-iterating-dictionary (SIM118)
  • global-at-module-level (PLW0604)
  • global-variable-not-assigned (PLW0602)
  • logging-format-interpolation (G001)
  • logging-not-lazy (G002)
  • multiple-imports (E401)
  • multiple-statements (E701, E702)
  • no-classmethod-decorator (PLR0202)
  • no-staticmethod-decorator (PLR0203)
  • protected-access (SLF001)
  • reimported (F811)
  • simplifiable-if-statement (SIM108)
  • singleton-comparison (E711, E712)
  • unidiomatic-typecheck (E721)
  • unnecessary-lambda (PLW0108)
  • unnecessary-pass (PIE790)
  • unnecessary-semicolon (E703)
  • unneeded-not -> Renamed to unnecessary-negation (SIM208)
  • useless-else-on-loop (PLW0120)
  • too-many-boolean-expressions (PLR0916)
  • too-many-nested-blocks (PLR1702)
  • too-many-statements (PLR0915)
  • wildcard-import (F403)
  • wrong-import-order (I001)
  • wrong-import-position (E402)
  • missing-final-newline (W292)
  • trailing-newlines (W391)
  • trailing-whitespace (W291)

Not explicitly mentioned in the pylintrc file but enabled:

  • typevar-name-incorrect-variance (PLC0105)
  • typevar-double-variance (PLC0131)
  • typevar-name-mismatch (PLC0132)
  • consider-using-dict-items (PLC0206)
  • use-sequence-for-iteration (PLC0208)
  • useless-import-alias (PLC0414)
  • use-implicit-booleaness-not-len (PLC1802)
  • non-ascii-name (PLC2401)
  • non-ascii-module-import (PLC2403)
  • unnecessary-dunder-call (PLC2801)
  • unnecessary-lambda-assignment (E731)
  • unnecessary-direct-lambda-call (PLC3002)
  • unsafe-yaml-load (S506)
  • nonlocal-and-global (PLE0115)
  • used-prior-global-declaration (PLE0118)
  • invalid-bytes-returned (PLE0308)
  • invalid-hash-returned (PLE0309)
  • potential-index-error (PLE0643)
  • await-outside-async (PLE1142)
  • mixed-format-string (F506)
  • singledispatch-method (PLE1519)
  • singledispatchmethod-function (PLE1520)
  • yield-inside-async-function (PLE1700)
  • bidirectional-unicode (PLE2502)
  • invalid-character-backspace (PLE2510)
  • invalid-character-sub (PLE2512)
  • invalid-character-esc (PLE2513)
  • invalid-character-nul (PLE2514)
  • invalid-character-zero-width-space (PLE2515)
  • modified-iterating-set (PLE4703)
  • keyword-arg-before-vararg (B026)

NOT Implemented

  • blacklisted-name -> Renamed to disallowed-name (❌)
  • abstract-class-instantiated (❌)
  • abstract-method (❌)
  • access-member-before-definition (❌)
  • anomalous-backslash-in-string (❌)
  • anomalous-unicode-escape-in-string (❌)
  • arguments-differ (❌)
  • assignment-from-no-return (❌)
  • assignment-from-none (❌)
  • attribute-defined-outside-init (❌)
  • bad-except-order (❌)
  • bad-format-string-key (❌)
  • bad-reversed-sequence (❌)
  • bad-super-call (❌) Not will be implemented in Ruff
  • catching-non-exception (❌)
  • confusing-with-statement (❌)
  • duplicate-argument-name (❌) Not will be implemented in Ruff
  • global-variable-undefined (❌)
  • import-error (❌)
  • inconsistent-mro (❌)
  • inherit-non-class (❌)
  • invalid-sequence-index (❌)
  • invalid-slice-index (❌)
  • invalid-slots-object (❌)
  • invalid-slots (❌)
  • invalid-unary-operand-type (❌)
  • logging-unsupported-format (❌)
  • method-hidden (❌)
  • missing-format-attribute (❌)
  • no-member (❌)
  • no-method-argument (❌)
  • no-name-in-module (❌)
  • no-value-for-parameter (❌)
  • non-iterator-returned (❌)
  • not-a-mapping (❌)
  • not-an-iterable (❌)
  • not-callable (❌)
  • not-context-manager (❌)
  • pointless-string-statement (❌)
  • raising-bad-type (❌)
  • raising-non-exception (❌)
  • redefined-outer-name (❌)
  • redundant-keyword-arg (❌)
  • signature-differs (❌)
  • super-init-not-called (❌)
  • too-many-function-args (❌)
  • undefined-loop-variable (❌)
  • unexpected-keyword-arg (❌)
  • unpacking-non-sequence (❌)
  • unreachable (❌)
  • unsubscriptable-object (❌)
  • unsupported-binary-operation (❌)
  • unsupported-membership-test (❌)
  • using-constant-test (❌)
  • invalid-characters-in-docstring (❌)
  • wrong-spelling-in-comment (❌)
  • wrong-spelling-in-docstring (❌)
  • bad-mcs-classmethod-argument (❌)
  • bad-mcs-method-argument (❌)
  • consider-using-enumerate (❌)
  • redundant-unittest-assert (❌)
  • superfluous-parens (❌)
  • deprecated-method (❌)
  • deprecated-module (❌)
  • mixed-line-endings (❌)
  • unexpected-line-ending-format (❌)

Others are not explicitly mentioned in the pylintrc file but are enabled:

  • wrong-spelling-in-comment (❌)
  • wrong-spelling-in-docstring (❌)
  • use-implicit-booleaness-not-comparison (❌)
  • bad-file-encoding (❌)
  • misplaced-format-function (❌)
  • class-variable-slots-conflict (❌)
  • invalid-class-object (❌)
  • invalid-enum-extension (❌)
  • declare-non-slot (❌)
  • invalid-length-hint-returned (❌)
  • invalid-format-returned (❌)
  • invalid-getnewargs-returned (❌)
  • invalid-getnewargs-ex-returned (❌)
  • dict-iter-missing-items (❌)
  • unhashable-member (❌)
  • invalid-slice-step (❌)
  • logging-format-truncated (❌)
  • invalid-envvar-value (❌)
  • not-async-context-manager (❌)
  • invalid-unicode-codec (❌)
  • invalid-character-carriage-return (❌)
  • positional-only-arguments-expected (❌)
  • invalid-field-call (❌)
  • modified-iterating-dict (❌)
  • raising-format-tuple (❌)
  • wrong-exception-operation (❌)
  • arguments-out-of-order (❌)

Disabled Rules

Implemented

  • invalid-name (N815)
  • ungrouped-imports (I001)
  • too-many-public-methods (PLR0904)
  • too-many-return-statements (PLR0911)
  • too-many-branches (PLR0912)
  • too-many-arguments (PLR0913)
  • too-many-locals (PLR0914)
  • no-else-return (RET505)
  • bad-indentation (E111)
  • fixme (FIX001, FIX002, FIX003, FIX004)
  • global-statement (PLW0603)
  • broad-exception-raised (TRY002)
  • logging-fstring-interpolation (G004)
  • unspecified-encoding (PLW1514)

NOT Implemented

  • use-maxsplit-arg (❌)
  • invalid-name (❌)
  • use-maxsplit-arg (❌)
  • consider-using-f-string (❌)
  • too-many-lines (❌) Not compatible with the Ruff Formatter
  • use-implicit-booleaness-not-comparison-to-string (❌) Not will be implemented in Ruff
  • use-implicit-booleaness-not-comparison-to-zero (❌) Not will be implemented in Ruff
  • duplicate-code (❌)
  • too-many-ancestors (❌)
  • too-many-instance-attributes (❌)
  • too-few-public-methods (❌)
  • unused-wildcard-import (❌)

These are Open edX custom rules that could not be implemented in Ruff because it does not have support for it yet

Enabled

  • non-parent-method-called
  • super-method-not-called
  • test-inherits-tests
  • translation-of-non-string
  • literal-used-as-attribute
  • simplifiable-range
  • wrong-assert-type
  • toggle-no-name
  • toggle-empty-description
  • toggle-missing-target-removal-date
  • toggle-non-boolean-default-value
  • toggle-missing-annotation
  • invalid-django-waffle-import
  • setting-boolean-default-value
  • filter-docstring-missing-purpose
  • filter-docstring-missing-or-incorrect-type
  • filter-docstring-missing-trigger

Disabled

  • feature-toggle-needs-doc
  • illegal-waffle-usage

These are rules that were not referenced in Pylint, nor as an Open edX Custom Rule (although they appear to be custom, but may have been removed)

Enabled

  • annotation-invalid-choice
  • annotation-duplicate-choice-value
  • annotation-missing-choice-value
  • annotation-invalid-token
  • annotation-duplicate-token
  • annotation-missing-token

These are the rules that are specific to Pylint and are not required in Ruff

  • astroid-error
  • fatal
  • method-check-failed
  • parse-error
  • raw-checker-failed
  • bad-inline-option
  • bad-option-value -> Renamed to:
    • useless-option-value
    • unknown-option-value
  • deprecated-pragma
  • unrecognized-inline-option
  • useless-suppression
  • locally-disabled
  • file-ignored
  • suppressed-message
  • use-symbolic-message-instead
  • bad-configuration-section
  • config-parse-error

And finally, these are the rules that would no longer be required by the Python version

  • return-arg-in-generator (⚠️) Not necessary for Python 3.3+
  • boolean-datetime (⚠️) Fixed in Python 3.5

Checklists

Check off if complete or not applicable:

Merge Checklist:

  • All reviewers approved
  • Reviewer tested the code following the testing instructions
  • CI build is green
  • Changelog entry added using scriv with a short description of the change
  • Documentation updated (not only docstrings)
  • Code dependencies reviewed
  • Fixup commits are squashed away
  • Unit tests added/updated
  • Noted any: Concerns, dependencies, migration issues, deadlines, tickets

Post Merge:

  • Trigger the release workflow to create a new GitHub release.
  • Check new version is pushed to PyPI after tag-triggered build is finished.
  • Delete working branch (if not needed anymore)
  • Upgrade the package in the Open edX platform requirements (if applicable)

@BryanttV BryanttV requested a review from a team March 25, 2025 23:21
@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Mar 25, 2025
@openedx-webhooks
Copy link

openedx-webhooks commented Mar 25, 2025

Thanks for the pull request, @BryanttV!

This repository is currently maintained by @openedx/committers-openedx-filters.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Mar 25, 2025
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Apr 1, 2025
@mphilbrick211
Copy link

Hi @openedx/hooks-extension-framework! Would someone be able to take a look at this?

In the meantime, @BryanttV can you resolve some of the conflicts that have popped up? Thanks!

@BryanttV BryanttV changed the title feat: replace pycodestyle, isort and pylint with ruff [POC] feat: replace pycodestyle, isort and pylint with ruff Jul 10, 2025
@mphilbrick211
Copy link

Hi @BryanttV! Is this pull request still in progress?

@openedx-webhooks openedx-webhooks added the core contributor PR author is a Core Contributor (who may or may not have write access to this repo). label Sep 16, 2025
@mphilbrick211 mphilbrick211 moved this from Ready for Review to Waiting on Author in Contributions Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Waiting on Author

Development

Successfully merging this pull request may close these issues.

3 participants