Don't raise none assignment warning when return type is not None (PY-28729)

This commit is contained in:
Semyon Proshev
2018-04-02 20:06:28 +03:00
parent 147e2499ed
commit dc4b93db04
2 changed files with 10 additions and 1 deletions
@@ -62,7 +62,7 @@ public class PyNoneFunctionAssignmentInspection extends PyInspection {
if (type instanceof PyNoneType && callee != null) {
final Condition<PyCallable> ignoredCallable = callable -> {
if (PySdkUtil.isElementInSkeletons(callable)) {
if (myTypeEvalContext.getReturnType(callable) != PyNoneType.INSTANCE || PySdkUtil.isElementInSkeletons(callable)) {
return true;
}
if (callable instanceof PyFunction) {
@@ -33,6 +33,15 @@ public class Py3NoneFunctionAssignmentInspectionTest extends PyInspectionTestCas
doMultiFileTest();
}
// PY-28729
public void testGenericSubstitutedWithNone() {
doTestByText(
"test1 = max([])\n" +
"test2 = max([], default=None)\n" +
"test3 = max([], default=0)"
);
}
@NotNull
@Override
protected Class<? extends PyInspection> getInspectionClass() {