Avoid erroneous class autofixes in indented blocks (#2226)
This commit is contained in:
@@ -157,7 +157,8 @@ pub fn convert_named_tuple_functional_to_class(
|
||||
violations::ConvertNamedTupleFunctionalToClass(typename.to_string()),
|
||||
Range::from_located(stmt),
|
||||
);
|
||||
if checker.patch(diagnostic.kind.rule()) {
|
||||
// TODO(charlie): Preserve indentation, to remove the first-column requirement.
|
||||
if checker.patch(diagnostic.kind.rule()) && stmt.location.column() == 0 {
|
||||
match match_defaults(keywords)
|
||||
.and_then(|defaults| create_properties_from_args(args, defaults))
|
||||
{
|
||||
|
||||
@@ -204,7 +204,8 @@ pub fn convert_typed_dict_functional_to_class(
|
||||
violations::ConvertTypedDictFunctionalToClass(class_name.to_string()),
|
||||
Range::from_located(stmt),
|
||||
);
|
||||
if checker.patch(diagnostic.kind.rule()) {
|
||||
// TODO(charlie): Preserve indentation, to remove the first-column requirement.
|
||||
if checker.patch(diagnostic.kind.rule()) && stmt.location.column() == 0 {
|
||||
match match_properties_and_total(args, keywords) {
|
||||
Ok((body, total_keyword)) => {
|
||||
diagnostic.amend(convert_to_class(
|
||||
|
||||
Reference in New Issue
Block a user