diff --git a/src/rust/engine/dep_inference/src/python/tests.rs b/src/rust/engine/dep_inference/src/python/tests.rs index f4a7c8099c4..fb300b50cf6 100644 --- a/src/rust/engine/dep_inference/src/python/tests.rs +++ b/src/rust/engine/dep_inference/src/python/tests.rs @@ -279,6 +279,8 @@ fn dunder_import() { ) # pants: no-infer-dep", &[], ); + + // Concatenated strings are accepted. assert_imports( " __import__( @@ -290,6 +292,11 @@ fn dunder_import() { ", &["foo.bar.xyzzy.funky"], ); + + // f-strings with interpolations are ignored + assert_imports("__import__(f'foo.{name}')", &[]); + assert_imports("__import__(f'foo.{{name}}')", &[]); + assert_imports("__import__(f'foo.bar\n')", &[]); } fn assert_imports_strong_weak(code: &str, strong: &[&str], weak: &[&str]) {