Repository navigation
Ruff new rules - #447
Merged
Merged
Ruff new rules#447
Conversation
Classes inherit from object implicitly in Python 3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use the zero-argument form of super(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
IOError is an alias of OSError since Python 3.3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove redundant parentheses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove a pass statement that follows other statements. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Don't explicitly return None from a function that never returns anything else. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use the explicit regex flag names (re.IGNORECASE rather than re.I). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use the datetime.UTC alias (Python 3.11+). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use the built-in set type in annotations instead of typing.Set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Import Iterable from collections.abc rather than typing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Write Optional[X] as X | None. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use f-strings instead of str.format(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sort the imports: standard library, third-party, then first-party modules, alphabetically. Aliased imports are combined with the others (combine-as-imports). The order change has no side effect: every module of the package still imports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Iterate over the keys or values of a dict directly when the other half is unused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use a dict comprehension instead of dict() around a generator. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
math.floor() already returns an int. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Name unused unpacked values _. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merge nested if statements that have no else branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Default the preserve argument to None instead of a shared dict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Annotate the shared encoding settings as a ClassVar. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bind the list of warnings of the current upload attempt to the callback that fills it. It was already used within the same attempt only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Open files with a with statement, which closes them even on error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pass check=False explicitly: every call already checks the return code itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use start_new_session=True, which runs setsid() in the child like preexec_fn=os.setsid did, without preexec_fn's risk of deadlocks in a multithreaded process (the output of ffmpeg is read from a thread). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace %-formatting with f-strings or str.format(). The output of the changed functions (sources, licenses, dates, sizes) is unchanged for sample inputs; %d becomes int() to keep truncating floats. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Log the errors that were silently ignored (stats updates, stats lock) instead of hiding them. The behaviour is unchanged: the task or the API call still goes on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Catch narrower exceptions where possible (subtitle decoding), log the others with their traceback, and mark the intentional ones: subtitle errors are reported to the user but must not fail the upload, and a task status that can't be read is shown with its traceback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Exempt the user-config.py files: Pywikibot requires this exact file name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
All the rules that Ruff 0.16+ enables by default now pass, so use them
instead of the explicit list, plus the pycodestyle and pyflakes rules
that are no longer in it. This also fixes the two violations that show
up with the complete set: an unnecessary encode("utf-8") argument
(UP012) and an unused noqa directive (RUF100).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ruff only checks the executable bit on Unix, so this was missed on Windows. Modules and configuration files are imported, never run directly: drop their shebang. The scripts in utils/ keep theirs and become executable (cron and the Toolforge job still call them with an explicit interpreter). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.