MAINT apply sorting of exported symbols in __all__
#2280
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the other follow-up discussed in #2265. It enables ruff rule
RUF022
to enable automatic sorting of symbols in__all__
.Note that peft currently uses a slightly outdated version of ruff: The pinning uses
ruff~=0.6.1
, which means that one currently gets 0.6.9. The current version of ruff is 0.8.3. The ruleRUF022
has still been a preview rule in 0.6.9, but in 0.8.3 is has went from preview to a standard rule, as visible from this list. To allow usingRUF022
I had to enable preview mode. I decided to combine it withexplicit-preview-rules
, which means that preview rules within a group should require explicit enabling/selecting.Regarding suppressing rule
F841
(unused variable): I assume that this rule also was only in preview in 0.6.9, whereas it is stable now as well. For some reasonexplicit-preview-rules
didn't really do its job properly in this case, becauseF841
is not explicitly listed inextend-select
, and yet ruff started to complain about unused variables now. For now I decided to add it to the ignore list.I also got one new lint for
C419
(unnecessary list comprehension), which I simply solved by converting it locally to a generator expression as intended by the lint.