Uh oh!
There was an error while loading. Please reload this page.
Fixes for ruff rule RUF012 - #8831
Closed
cclauss wants to merge 2 commits into
Closed
Conversation
dhruvmanila
commented
Jun 21, 2023
Member
I think we should wait. We've received a few issues with the latest changes to this rule. |
dhruvmanila
marked this pull request as draft
June 21, 2023 18:14
cclauss
commented
Jun 22, 2023
MemberAuthor
All new PRs are failing. Should we ignore RUF012 in pyproject.tml? |
dhruvmanila
commented
Jun 22, 2023
Member
Yeah, that's fine for now. |
cclauss
commented
Jun 22, 2023
MemberAuthor
Closing in favor of #8802 |
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 freeto 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.
Describe your change:
%
ruff rule RUF012mutable-class-default (RUF012)
Derived from the Ruff-specific rules linter.
What it does
Checks for mutable default values in class attributes.
Why is this bad?
Mutable default values share state across all instances of the class,
while not being obvious. This can lead to bugs when the attributes are
changed in one instance, as those changes will unexpectedly affect all
other instances.
When mutable value are intended, they should be annotated with
typing.ClassVar.Examples
Use instead:
Checklist:
Fixes: #{$ISSUE_NO}.