Don't raise D208 when last line is non-empty (#13372)

Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
ukyen 2024-09-26 13:53:21 +01:00 committed by GitHub
parent ae39ce56c0
commit e83388dcea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 253 additions and 29 deletions

View file

@ -46,3 +46,42 @@ pub mod upstream_categories;
pub mod test;
pub const RUFF_PKG_VERSION: &str = env!("CARGO_PKG_VERSION");
#[cfg(test)]
mod tests {
use std::path::Path;
use ruff_python_ast::PySourceType;
use crate::codes::Rule;
use crate::settings::LinterSettings;
use crate::source_kind::SourceKind;
use crate::test::{print_messages, test_contents};
/// Test for ad-hoc debugging.
#[test]
#[ignore]
fn linter_quick_test() {
let code = r#"class Platform:
""" Remove sampler
Args:
    Returns:
"""
"#;
let source_type = PySourceType::Python;
let rule = Rule::OverIndentation;
let source_kind = SourceKind::from_source_code(code.to_string(), source_type)
.expect("Source code should be valid")
.expect("Notebook to contain python code");
let (diagnostics, fixed) = test_contents(
&source_kind,
Path::new("ruff_linter/rules/quick_test"),
&LinterSettings::for_rule(rule),
);
assert_eq!(print_messages(&diagnostics), "");
assert_eq!(fixed.source_code(), code);
}
}