Skip to content

Commit a41ac8c

Browse files
SONARPY-1825 Return Python.UNKNOWN instead of ObjectType[PythonType.UNKNOWN] for unknown call expressions (#1795)
1 parent 3980042 commit a41ac8c

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

python-frontend/src/main/java/org/sonar/python/tree/CallExpressionImpl.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,6 @@ public PythonType typeV2() {
189189
if (callee().typeV2() instanceof ClassType classType) {
190190
return new ObjectType(classType);
191191
}
192-
if (callee().typeV2() instanceof FunctionType functionType) {
193-
return new ObjectType(functionType.returnType());
194-
}
195192
return PythonType.UNKNOWN;
196193
}
197194
}

python-frontend/src/test/java/org/sonar/python/semantic/v2/TypeInferenceV2Test.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,6 @@ void annotation_without_reassignment() {
574574
}
575575

576576
@Test
577-
@Disabled("ObjectType[PythonType.UNKNOWN] should just be PythonType.UNKNOWN")
578577
void call_expression() {
579578
assertThat(lastExpression(
580579
"f()").typeV2()).isEqualTo(PythonType.UNKNOWN);
@@ -607,14 +606,13 @@ def foo(): a
607606
}
608607

609608
@Test
610-
@Disabled("Flow insensitive type inference scope issue")
611609
void variable_outside_function_3() {
612610
assertThat(lastExpression(
613611
"""
614612
def foo():
615613
a = 42
616614
a
617-
""").type()).isEqualTo(PythonType.UNKNOWN);
615+
""").typeV2()).isEqualTo(PythonType.UNKNOWN);
618616
}
619617

620618
@Test

0 commit comments

Comments
 (0)