Enable autofix for over- and under-indented docstrings (#451)

This commit is contained in:
Charlie Marsh 2022-10-17 21:43:38 -04:00 committed by GitHub
parent f832f88c75
commit 36fe8b76d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 230 additions and 91 deletions

View file

@ -32,3 +32,11 @@ pub fn indentation<'a>(checker: &'a mut Checker, docstring: &Expr) -> &'a str {
end_location: Location::new(range.location.row(), range.location.column()),
})
}
/// Replace any non-whitespace characters from an indentation string.
pub fn clean(indentation: &str) -> String {
indentation
.chars()
.map(|char| if char.is_whitespace() { char } else { ' ' })
.collect()
}