Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use ruff_diagnostics::Applicability;
use ruff_macros::{ViolationMetadata, derive_message_formats};
use ruff_python_ast as ast;
use ruff_text_size::Ranged;
Expand Down Expand Up @@ -61,14 +62,23 @@ pub(crate) fn useless_object_inheritance(checker: &Checker, class_def: &ast::Stm
},
base.range(),
);

diagnostic.try_set_fix(|| {
remove_argument(
let edit = remove_argument(
base,
arguments,
Parentheses::Remove,
checker.locator().contents(),
)
.map(Fix::safe_edit)
)?;

let range = edit.range();
let applicability = if checker.comment_ranges().intersects(range) {
Applicability::Unsafe
} else {
Applicability::Safe
};

Ok(Fix::applicable_edit(edit, applicability))
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ UP004.py:16:5: UP004 [*] Class `A` inherits from `object`
|
= help: Remove `object` inheritance

Safe fix
Unsafe fix
12 12 | ...
13 13 |
14 14 |
Expand All @@ -75,7 +75,7 @@ UP004.py:24:5: UP004 [*] Class `A` inherits from `object`
|
= help: Remove `object` inheritance

Safe fix
Unsafe fix
19 19 | ...
20 20 |
21 21 |
Expand All @@ -99,7 +99,7 @@ UP004.py:31:5: UP004 [*] Class `A` inherits from `object`
|
= help: Remove `object` inheritance

Safe fix
Unsafe fix
26 26 | ...
27 27 |
28 28 |
Expand All @@ -122,7 +122,7 @@ UP004.py:37:5: UP004 [*] Class `A` inherits from `object`
|
= help: Remove `object` inheritance

Safe fix
Unsafe fix
33 33 | ...
34 34 |
35 35 |
Expand All @@ -146,7 +146,7 @@ UP004.py:45:5: UP004 [*] Class `A` inherits from `object`
|
= help: Remove `object` inheritance

Safe fix
Unsafe fix
40 40 | ...
41 41 |
42 42 |
Expand All @@ -171,7 +171,7 @@ UP004.py:53:5: UP004 [*] Class `A` inherits from `object`
|
= help: Remove `object` inheritance

Safe fix
Unsafe fix
48 48 | ...
49 49 |
50 50 |
Expand All @@ -196,7 +196,7 @@ UP004.py:61:5: UP004 [*] Class `A` inherits from `object`
|
= help: Remove `object` inheritance

Safe fix
Unsafe fix
56 56 | ...
57 57 |
58 58 |
Expand All @@ -221,7 +221,7 @@ UP004.py:69:5: UP004 [*] Class `A` inherits from `object`
|
= help: Remove `object` inheritance

Safe fix
Unsafe fix
64 64 | ...
65 65 |
66 66 |
Expand Down Expand Up @@ -320,7 +320,7 @@ UP004.py:98:5: UP004 [*] Class `B` inherits from `object`
|
= help: Remove `object` inheritance

Safe fix
Unsafe fix
95 95 |
96 96 |
97 97 | class B(
Expand Down Expand Up @@ -381,7 +381,7 @@ UP004.py:125:5: UP004 [*] Class `A` inherits from `object`
|
= help: Remove `object` inheritance

Safe fix
Unsafe fix
121 121 | ...
122 122 |
123 123 |
Expand All @@ -403,7 +403,7 @@ UP004.py:131:5: UP004 [*] Class `A` inherits from `object`
|
= help: Remove `object` inheritance

Safe fix
Unsafe fix
127 127 | ...
128 128 |
129 129 |
Expand Down
Loading