-
Couldn't load subscription status.
- Fork 20
[POC] feat: replace pycodestyle, isort and pylint with ruff
#275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Thanks for the pull request, @BryanttV! This repository is currently maintained by 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 approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo 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:
🔘 Get a green buildIf 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:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
|
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! |
pycodestyle, isort and pylint with ruffpycodestyle, isort and pylint with ruff
|
Hi @BryanttV! Is this pull request still in progress? |
2a21424 to
8dd1b47
Compare
Description
This PR replaces
pycodestyle,isortandpylint(partially).Testing instructions
You can run
make qualityin your local or see the PR checks.Supporting information
pydocstylewithruff#270 (comment)Deadline
None
Other information
pycodestyleandisortcan be completely replaced withruffbut not withpylint. More information in Ruff and Pylint comparisonBelow is the detail of each rule. Here is an issue with the pylint rules implemented in Ruff (astral-sh/ruff#970) In summary:
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 enabledtoo-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 pydocstylemissing-class-docstring(D101) Disabled in pydocstylemissing-function-docstring(D103) Enabled in pydocstyleempty-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 tobroad-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 tounnecessary-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
pylintrcfile 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 todisallowed-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 Ruffcatching-non-exception(❌)confusing-with-statement(❌)duplicate-argument-name(❌) Not will be implemented in Ruffglobal-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
pylintrcfile 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 Formatteruse-implicit-booleaness-not-comparison-to-string(❌) Not will be implemented in Ruffuse-implicit-booleaness-not-comparison-to-zero(❌) Not will be implemented in Ruffduplicate-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-calledsuper-method-not-calledtest-inherits-teststranslation-of-non-stringliteral-used-as-attributesimplifiable-rangewrong-assert-typetoggle-no-nametoggle-empty-descriptiontoggle-missing-target-removal-datetoggle-non-boolean-default-valuetoggle-missing-annotationinvalid-django-waffle-importsetting-boolean-default-valuefilter-docstring-missing-purposefilter-docstring-missing-or-incorrect-typefilter-docstring-missing-triggerDisabled
feature-toggle-needs-docillegal-waffle-usageThese 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-choiceannotation-duplicate-choice-valueannotation-missing-choice-valueannotation-invalid-tokenannotation-duplicate-tokenannotation-missing-tokenThese are the rules that are specific to Pylint and are not required in Ruff
astroid-errorfatalmethod-check-failedparse-errorraw-checker-failedbad-inline-optionbad-option-value-> Renamed to:useless-option-valueunknown-option-valuedeprecated-pragmaunrecognized-inline-optionuseless-suppressionlocally-disabledfile-ignoredsuppressed-messageuse-symbolic-message-insteadbad-configuration-sectionconfig-parse-errorAnd finally, these are the rules that would no longer be required by the Python version
return-arg-in-generator(boolean-datetime(Checklists
Check off if complete or not applicable:
Merge Checklist:
Post Merge: