Skip to content

Commit 247d534

Browse files
Fix NPE on S5642 (#1678)
1 parent a18bd20 commit 247d534

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

python-checks/src/main/java/org/sonar/python/checks/UseOfAnyAsTypeHintCheck.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
package org.sonar.python.checks;
2121

22+
import java.util.Objects;
2223
import java.util.Optional;
2324
import java.util.Set;
2425
import java.util.function.Predicate;
@@ -72,6 +73,7 @@ private static boolean hasFunctionOverrideOrOverloadDecorator(FunctionDef curren
7273
return currentFunctionDef.decorators().stream()
7374
.map(Decorator::expression)
7475
.map(TreeUtils::fullyQualifiedNameFromExpression)
76+
.filter(Objects::nonNull)
7577
.anyMatch(OVERRIDE_FQNS::contains);
7678
}
7779

python-checks/src/test/resources/checks/useOfAnyAsTypeHint.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,7 @@ def other_function(self, other: Any, text: str) -> None: # Compliant
114114

115115
def return_type_check(self, text) -> Any: # Compliant
116116
...
117+
118+
@my_annotation[42]
119+
def some_annotated_method(self, text: Any): # Noncompliant
120+
...

0 commit comments

Comments
 (0)