Implement F841 (for exception handlers) (#63)

This commit is contained in:
Charlie Marsh 2022-08-31 18:40:34 -04:00 committed by GitHub
parent 3f739214b4
commit b5edcee9f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 62 additions and 1 deletions

View file

@ -354,6 +354,30 @@ mod tests {
Ok(())
}
#[test]
fn f841() -> Result<()> {
let actual = check_path(
&Path::new("./resources/test/src/F841.py"),
&settings::Settings {
line_length: 88,
exclude: vec![],
select: BTreeSet::from([CheckCode::F841]),
},
&cache::Mode::None,
)?;
let expected = vec![Message {
kind: CheckKind::UnusedVariable("e".to_string()),
location: Location::new(3, 1),
filename: "./resources/test/src/F841.py".to_string(),
}];
assert_eq!(actual.len(), expected.len());
for i in 0..actual.len() {
assert_eq!(actual[i], expected[i]);
}
Ok(())
}
#[test]
fn f901() -> Result<()> {
let actual = check_path(