Skip to content

Commit

Permalink
CR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
maksim-grebeniuk-sonarsource committed Oct 25, 2024
1 parent ecd1521 commit 7bba13e
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,17 @@ public void visitName(Name name) {
.map(Expression.class::cast)
.map(Expression::typeV2)
// TODO: classes (SONARPY-1829) and functions should be propagated like other types
.filter(t -> (t instanceof ClassType) || (t instanceof FunctionType) || (t instanceof ModuleType) || (t instanceof UnknownType.UnresolvedImportType))
.filter(TrivialTypeInferenceVisitor::shouldTypeBeEagerlyPropagated)
.ifPresent(type -> setTypeToName(name, type));
}

private static boolean shouldTypeBeEagerlyPropagated(PythonType t) {
return (t instanceof ClassType)
|| (t instanceof FunctionType)
|| (t instanceof ModuleType)
|| (t instanceof UnknownType.UnresolvedImportType);
}

private PythonType currentType() {
return typeStack.peek();
}
Expand Down

0 comments on commit 7bba13e

Please sign in to comment.