From bf4722a62fc4f4c75ddb364fb099794e55a0456e Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Fri, 2 Sep 2022 08:56:26 -0400 Subject: [PATCH] Fix future-to-__future__ typo (#85) --- resources/test/src/F401.py | 1 + src/check_ast.rs | 4 +--- src/linter.rs | 6 +++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/resources/test/src/F401.py b/resources/test/src/F401.py index 680d555452..a2c80fd295 100644 --- a/resources/test/src/F401.py +++ b/resources/test/src/F401.py @@ -1,3 +1,4 @@ +from __future__ import all_feature_names import os import functools from collections import ( diff --git a/src/check_ast.rs b/src/check_ast.rs index 9504bf369a..9af0f9d61e 100644 --- a/src/check_ast.rs +++ b/src/check_ast.rs @@ -195,12 +195,11 @@ impl Visitor for Checker<'_> { .asname .clone() .unwrap_or_else(|| alias.node.name.clone()); - if let Some("future") = module.as_deref() { + if let Some("__future__") = module.as_deref() { self.add_binding( name, Binding { kind: BindingKind::FutureImportation, - used: Some(self.scopes.last().expect("No current scope found.").id), location: stmt.location, }, @@ -210,7 +209,6 @@ impl Visitor for Checker<'_> { name, Binding { kind: BindingKind::StarImportation, - used: None, location: stmt.location, }, diff --git a/src/linter.rs b/src/linter.rs index f9513356e3..a1e9bef9c5 100644 --- a/src/linter.rs +++ b/src/linter.rs @@ -103,17 +103,17 @@ mod tests { let expected = vec![ Message { kind: CheckKind::UnusedImport("logging.handlers".to_string()), - location: Location::new(11, 1), + location: Location::new(12, 1), filename: "./resources/test/src/F401.py".to_string(), }, Message { kind: CheckKind::UnusedImport("functools".to_string()), - location: Location::new(2, 1), + location: Location::new(3, 1), filename: "./resources/test/src/F401.py".to_string(), }, Message { kind: CheckKind::UnusedImport("collections.OrderedDict".to_string()), - location: Location::new(3, 1), + location: Location::new(4, 1), filename: "./resources/test/src/F401.py".to_string(), }, ];