Skip to content

Commit

Permalink
Fix NPE on S5642 (#1678)
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-dequenne-sonarsource committed Dec 5, 2023
1 parent a18bd20 commit 247d534
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package org.sonar.python.checks;

import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.Predicate;
Expand Down Expand Up @@ -72,6 +73,7 @@ private static boolean hasFunctionOverrideOrOverloadDecorator(FunctionDef curren
return currentFunctionDef.decorators().stream()
.map(Decorator::expression)
.map(TreeUtils::fullyQualifiedNameFromExpression)
.filter(Objects::nonNull)
.anyMatch(OVERRIDE_FQNS::contains);
}

Expand Down
4 changes: 4 additions & 0 deletions python-checks/src/test/resources/checks/useOfAnyAsTypeHint.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,7 @@ def other_function(self, other: Any, text: str) -> None: # Compliant

def return_type_check(self, text) -> Any: # Compliant
...

@my_annotation[42]
def some_annotated_method(self, text: Any): # Noncompliant
...

0 comments on commit 247d534

Please sign in to comment.