Avoid erroneous class autofixes in indented blocks (#2226)

This commit is contained in:
Charlie Marsh
2023-01-26 16:24:21 -05:00
committed by GitHub
parent 0cab3f8437
commit 224334b6d1
2 changed files with 4 additions and 2 deletions

View File

@@ -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))
{

View File

@@ -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(