Skip to content

Commit

Permalink
add a test case from SONARPY-2244
Browse files Browse the repository at this point in the history
  • Loading branch information
maksim-grebeniuk-sonarsource committed Oct 24, 2024
1 parent f121860 commit ecd1521
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,21 @@ class A(Parent): ...
.isEqualTo("unknown.Parent");
}

@Test
void testUnresolvedImportTypePropagationInsideFunctions() {
var fileInput = inferTypes("""
from a import b
def function():
f(b)
""");
var functionDef = (FunctionDef) fileInput.statements().statements().get(1);
var funcCall = ((ExpressionStatement) functionDef.body().statements().get(0)).expressions().get(0);
var arg = ((RegularArgument) ((CallExpression) funcCall).arguments().get(0));
var argType = arg.expression().typeV2();

assertThat(argType).isInstanceOfSatisfying(UnresolvedImportType.class, a -> assertThat(a.importPath()).isEqualTo("a.b")); // FAILS
}

@Test
void testProjectLevelSymbolTableImports() {
var classSymbol = new ClassSymbolImpl("C", "something.known.C");
Expand Down

0 comments on commit ecd1521

Please sign in to comment.