mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-80147 Handle type of tuple expression being null in PyStringFormatInspection
It can be null if, for example, a Python interpreter is not configured and a tuple of strings is used as a rightExpression GitOrigin-RevId: 23564503422a75de7b538dec3400fb8dd284cd73
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2f58d0bbb3
commit
169e409d30
+3
-1
@@ -142,7 +142,9 @@ public final class PyStringFormatInspection extends PyInspection {
|
||||
}
|
||||
else {
|
||||
final PyTupleType tupleType = (PyTupleType)myTypeEvalContext.getType(rightExpression);
|
||||
assert tupleType != null;
|
||||
if (tupleType == null) {
|
||||
return -1;
|
||||
}
|
||||
matchEntireTupleTypes(problemTarget, tupleType);
|
||||
return tupleType.getElementCount();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
a = ("b", "c")
|
||||
d = "%s" % a
|
||||
@@ -119,6 +119,10 @@ public abstract class PyTestCase extends UsefulTestCase {
|
||||
|
||||
protected void assertSdkRootsNotParsed(@NotNull PsiFile currentFile) {
|
||||
final Sdk testSdk = PythonSdkUtil.findPythonSdk(currentFile);
|
||||
if (testSdk == null) {
|
||||
LOG.warn("testSdk is null. assertSdkRootsNotParsed is skipped");
|
||||
return;
|
||||
}
|
||||
for (VirtualFile root : testSdk.getRootProvider().getFiles(OrderRootType.CLASSES)) {
|
||||
assertRootNotParsed(currentFile, root, null);
|
||||
}
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.jetbrains.python.inspections;
|
||||
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.jetbrains.python.fixtures.PyInspectionTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PyStringFormatNoSDKInspectionTest extends PyInspectionTestCase {
|
||||
|
||||
@Override
|
||||
protected @Nullable LightProjectDescriptor getProjectDescriptor() {
|
||||
return LightProjectDescriptor.EMPTY_PROJECT_DESCRIPTOR;
|
||||
}
|
||||
|
||||
// PY-80147
|
||||
public void testTupleFormat() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Class<? extends PyInspection> getInspectionClass() {
|
||||
return PyStringFormatInspection.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isLowerCaseTestFile() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user