-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
fixesRelated to suggested fixes for violationsRelated to suggested fixes for violationsgood first issueGood for newcomersGood for newcomerspreviewRelated to preview mode featuresRelated to preview mode features
Description
This comment will be deleted:
import abc
class C(
other_kwarg=1,
# comment
metaclass=abc.ABCMeta,
):
passhttps://play.ruff.rs/f64dfdc1-811d-466f-8e49-0f400e1859d0
We should make the fix unsafe here if there are comments in the deletion range, as well as when there are other base classes:
ruff/crates/ruff_linter/src/rules/refurb/rules/metaclass_abcmeta.rs
Lines 85 to 89 in b80d8ff
| let applicability = if class_def.bases().is_empty() { | |
| Applicability::Safe | |
| } else { | |
| Applicability::Unsafe | |
| }; |
and update the fix safety docs to reflect the other way the fix can be unsafe:
ruff/crates/ruff_linter/src/rules/refurb/rules/metaclass_abcmeta.rs
Lines 41 to 44 in b80d8ff
| /// ## Fix safety | |
| /// The rule's fix is unsafe if the class has base classes. This is because the base classes might | |
| /// be validating the class's other base classes (e.g., `typing.Protocol` does this) or otherwise | |
| /// alter runtime behavior if more base classes are added. |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
fixesRelated to suggested fixes for violationsRelated to suggested fixes for violationsgood first issueGood for newcomersGood for newcomerspreviewRelated to preview mode featuresRelated to preview mode features