diff --git a/python/build/plugin-list.txt b/python/build/plugin-list.txt
index 0b27fa9432c9..aa7830f304c8 100644
--- a/python/build/plugin-list.txt
+++ b/python/build/plugin-list.txt
@@ -11,3 +11,9 @@ tasks-core
tasks-api
github
terminal
+IntelliLang
+IntelliLang-xml
+IntelliLang-js
+IntelliLang-python
+rest
+python-rest
diff --git a/python/build/pycharm_build.gant b/python/build/pycharm_build.gant
index ae2e7edac56e..7709e90dbf9f 100644
--- a/python/build/pycharm_build.gant
+++ b/python/build/pycharm_build.gant
@@ -60,8 +60,8 @@ setProperty("buildName", "PY-$buildNumber")
target('default': "Build artifacts") {
def modules = [
- "python-pydev", "colorSchemes", pycharmPlatformApiModules(), platformUltimateImplementationModules, pycharmImplementationModules(), pluginFilter
- ].flatten()
+ "python-pydev", "colorSchemes", pycharmPlatformApiModules(), platformUltimateImplementationModules,
+ pycharmImplementationModules(), pluginFilter, "platform-main"].flatten()
loadProject()
@@ -156,8 +156,26 @@ target('default': "Build artifacts") {
buildMacZip(macAppRoot, "${paths.artifacts}/pycharm${buildName}.sit", [paths.distAll], paths.distMac)
signMacZip("pycharm")
buildDmg("pycharm", "${home}/python/build/DMG_background.png")
+
+ communityEdition(usedJars)
}
+private communityEdition(Set usedJars) {
+ Script s = groovyShell.parse(new File("$pythonCommunityHome/build/pycharm_community_build.gant"))
+ s.setBinding(binding)
+
+ s.layoutCommunity(usedJars)
+
+ // todo: get rid of copying
+ //ant.copy(file: "$paths.artifacts/ideaIC-${buildNumber}.mac.zip", tofile: "$paths.artifacts/ideaIC-${buildNumber}.sit")
+ //def extraArgs = ["build.number": "IC-$buildNumber"]
+ //signMacZip("idea", extraArgs)
+ //notifyArtifactBuilt("$paths.artifacts/ideaIC-${buildNumber}.sit")
+ //buildDmg("idea", getDmgImage(true), extraArgs)
+ //ant.delete(file: "$paths.artifacts/ideaIC-${buildNumber}.sit")
+}
+
+
private layoutPlugins(layouts) {
dir("plugins") {
layouts.layoutPlugin("django-db-config")
diff --git a/python/build/pycharm_community_build.gant b/python/build/pycharm_community_build.gant
index dcef5ac8f66f..e245ca7e31e5 100644
--- a/python/build/pycharm_community_build.gant
+++ b/python/build/pycharm_community_build.gant
@@ -107,9 +107,9 @@ target('default': "Build artifacts") {
def normalizedHome = ch.replace('\\', '/')
def normalizedPythonHome = pythonCommunityHome.replace('\\', '/')
def approvedJars = ["$normalizedHome/lib/", "$normalizedPythonHome/lib/", "$normalizedHome/xml/relaxng/lib/"]
- def usedJars = buildModulesAndCollectUsedJars(modules, approvedJars, [])
+ def usedJars = buildModulesAndCollectUsedJars(modules, approvedJars, ["/ant/"])
- layoutCommunity(paths, usedJars)
+ layoutCommunity(usedJars)
buildWinZip("${paths.artifacts}/pycharm${buildName}.zip", [paths.distAll, paths.distWin])
@@ -119,18 +119,14 @@ target('default': "Build artifacts") {
"pycharm", false, true, system_selector)
*/
- String tarRoot = isEap() ? "pycharm-community-$buildNumber" : "pycharm-community-${p("component.version.major")}.${p("component.version.minor")}"
- buildTarGz(tarRoot, "$paths.artifacts/pycharm${buildName}.tar", [paths.distAll, paths.distUnix])
-
/*
- String macAppRoot = isEap() ? "PyCharm ${p("component.version.major")}.${p("component.version.minor")} EAP.app" : "PyCharm.app"
- buildMacZip(macAppRoot, "${paths.artifacts}/pycharm${buildName}.sit", [paths.distAll], paths.distMac)
signMacZip("pycharm")
buildDmg("pycharm", "${home}/python/build/DMG_background.png")
*/
}
-public layoutCommunity(Paths paths, Set usedJars) {
+public layoutCommunity(Set usedJars) {
+ def paths = new Paths(home)
buildSearchableOptions("${projectBuilder.moduleOutput(findModule("platform-resources"))}/search", [], {
projectBuilder.moduleRuntimeClasspath(findModule("main_pycharm_ce"), false).each {
ant.pathelement(location: it)
@@ -166,6 +162,12 @@ public layoutCommunity(Paths paths, Set usedJars) {
"$pythonCommunityHome/resources"]
buildWinLauncher("$ch", "$ch/bin/WinLauncher/WinLauncher.exe", launcher,
appInfoFile(), "$pythonCommunityHome/build/pycharm_community_launcher.properties", system_selector, resourcePaths)
+
+ String tarRoot = isEap() ? "pycharm-community-$buildNumber" : "pycharm-community-${p("component.version.major")}.${p("component.version.minor")}"
+ buildTarGz(tarRoot, "$paths.artifacts/pycharm${buildName}.tar", [paths.distAll, paths.distUnix])
+
+ String macAppRoot = isEap() ? "PyCharm Community Edition ${p("component.version.major")}.${p("component.version.minor")} EAP.app" : "PyCharm Community Edition.app"
+ buildMacZip(macAppRoot, "${paths.artifacts}/pycharm${buildName}.sit", [paths.distAll], paths.distMac)
}
private layoutPlugins(layouts) {
@@ -187,8 +189,10 @@ private layoutPlugins(layouts) {
layouts.layoutPlugin("python-uml")
layouts.layoutPlugin("localization")
layouts.layoutPlugin("python-localization")
+ */
layouts.layoutPlugin("rest")
layouts.layoutPlugin("python-rest")
+ /*
layouts.layoutPlugin("pycharm-flask")
layouts.layoutPlugin("pycharm-numpy")
layouts.layoutPlugin("textmate") {
diff --git a/python/build/pycharm_community_launcher.properties b/python/build/pycharm_community_launcher.properties
index 45401043671d..409b83d09f3b 100644
--- a/python/build/pycharm_community_launcher.properties
+++ b/python/build/pycharm_community_launcher.properties
@@ -1,3 +1,3 @@
IDS_JDK_ENV_VAR=PYCHARM_JDK
IDS_JDK_ONLY=false
-IDS_VM_OPTIONS=-Didea.platform.prefix=PythonCore -Didea.no.jre.check=true -Didea.paths.selector=__PRODUCT_PATHS_SELECTOR__
+IDS_VM_OPTIONS=-Didea.platform.prefix=PyCharmCore -Didea.no.jre.check=true -Didea.paths.selector=__PRODUCT_PATHS_SELECTOR__
diff --git a/python/python-rest/python-rest.iml b/python/python-rest/python-rest.iml
index 8a8362ee46ee..53606293d8d0 100644
--- a/python/python-rest/python-rest.iml
+++ b/python/python-rest/python-rest.iml
@@ -11,10 +11,10 @@
-
-
+
+
diff --git a/python/python-rest/src/com/jetbrains/rest/RestEditorHighlighter.java b/python/python-rest/src/com/jetbrains/rest/RestEditorHighlighter.java
index f8660042eaef..df35b9f1104e 100644
--- a/python/python-rest/src/com/jetbrains/rest/RestEditorHighlighter.java
+++ b/python/python-rest/src/com/jetbrains/rest/RestEditorHighlighter.java
@@ -4,11 +4,12 @@ import com.intellij.openapi.editor.colors.EditorColors;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.ex.util.LayerDescriptor;
import com.intellij.openapi.editor.ex.util.LayeredLexerEditorHighlighter;
+import com.intellij.openapi.fileTypes.FileType;
+import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
-import com.jetbrains.django.lang.template.DjangoTemplateFileType;
import com.jetbrains.python.PythonFileType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -26,9 +27,12 @@ public class RestEditorHighlighter extends LayeredLexerEditorHighlighter {
registerLayer(RestTokenTypes.PYTHON_LINE, new LayerDescriptor(
SyntaxHighlighterFactory.getSyntaxHighlighter(PythonFileType.INSTANCE, project, file), "", EditorColors.INJECTED_LANGUAGE_FRAGMENT));
- registerLayer(RestTokenTypes.DJANGO_LINE, new LayerDescriptor(
- SyntaxHighlighterFactory.getSyntaxHighlighter(DjangoTemplateFileType.INSTANCE, project, file), "", EditorColors.INJECTED_LANGUAGE_FRAGMENT));
-
+ FileType djangoTemplateFileType = FileTypeManager.getInstance().findFileTypeByName("DjangoTemplate");
+ if (djangoTemplateFileType != null) {
+ registerLayer(RestTokenTypes.DJANGO_LINE, new LayerDescriptor(
+ SyntaxHighlighterFactory.getSyntaxHighlighter(djangoTemplateFileType, project, file), "",
+ EditorColors.INJECTED_LANGUAGE_FRAGMENT));
+ }
registerLayer(RestTokenTypes.JAVASCRIPT_LINE, new LayerDescriptor(
SyntaxHighlighterFactory.getSyntaxHighlighter(StdFileTypes.JS, project, file), "", EditorColors.INJECTED_LANGUAGE_FRAGMENT));
diff --git a/python/python-rest/src/com/jetbrains/rest/RestFileViewProvider.java b/python/python-rest/src/com/jetbrains/rest/RestFileViewProvider.java
index 84d053ccd4ab..ec09184bc69b 100644
--- a/python/python-rest/src/com/jetbrains/rest/RestFileViewProvider.java
+++ b/python/python-rest/src/com/jetbrains/rest/RestFileViewProvider.java
@@ -10,7 +10,6 @@ import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.impl.source.PsiFileImpl;
import com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider;
-import com.jetbrains.django.lang.template.DjangoTemplateLanguage;
import com.jetbrains.python.PythonLanguage;
import org.jetbrains.annotations.NotNull;
@@ -51,7 +50,10 @@ public class RestFileViewProvider extends MultiplePsiFilesPerDocumentFileViewPro
if (myLanguages == null) {
myLanguages = Sets.newLinkedHashSet();
myLanguages.add(getBaseLanguage());
- myLanguages.add(DjangoTemplateLanguage.INSTANCE);
+ Language djangoTemplateLanguage = Language.findLanguageByID("DjangoTemplate");
+ if (djangoTemplateLanguage != null) {
+ myLanguages.add(djangoTemplateLanguage);
+ }
myLanguages.add(getTemplateDataLanguage());
}
return myLanguages;
@@ -66,7 +68,7 @@ public class RestFileViewProvider extends MultiplePsiFilesPerDocumentFileViewPro
file.setContentElementType(RestPythonElementTypes.PYTHON_BLOCK_DATA);
return file;
}
- else if (lang == DjangoTemplateLanguage.INSTANCE) {
+ else if (lang.getID().equals("DjangoTemplate")) {
PsiFileImpl file = (PsiFileImpl)def.createFile(this);
file.setContentElementType(RestPythonElementTypes.DJANGO_BLOCK_DATA);
return file;
diff --git a/python/python-tests.iml b/python/python-tests.iml
index ca3b8d3f300c..9a5cba3ab8e4 100644
--- a/python/python-tests.iml
+++ b/python/python-tests.iml
@@ -27,6 +27,7 @@
+
diff --git a/python/resources/PyCharmCore.ico b/python/resources/PyCharmCore.ico
new file mode 100644
index 000000000000..157c83e9d39a
Binary files /dev/null and b/python/resources/PyCharmCore.ico differ
diff --git a/python/resources/idea/PyCharmCoreApplicationInfo.xml b/python/resources/idea/PyCharmCoreApplicationInfo.xml
index 2bc5ab48ee90..7ecb2013f08e 100644
--- a/python/resources/idea/PyCharmCoreApplicationInfo.xml
+++ b/python/resources/idea/PyCharmCoreApplicationInfo.xml
@@ -4,7 +4,7 @@
-
+
diff --git a/python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java b/python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java
index de61831e52ac..7d7abff11d65 100644
--- a/python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java
+++ b/python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java
@@ -236,6 +236,30 @@ public class PyControlFlowBuilder extends PyRecursiveElementVisitor {
return head.get();
}
+ @Override
+ public void visitPyConditionalExpression(PyConditionalExpression node) {
+ myBuilder.startNode(node);
+ final PyExpression condition = node.getCondition();
+ final PyTypeAssertionEvaluator assertionEvaluator = new PyTypeAssertionEvaluator();
+ if (condition != null) {
+ condition.accept(this);
+ condition.accept(assertionEvaluator);
+ }
+ final Instruction branchingPoint = myBuilder.prevInstruction;
+ final PyExpression truePart = node.getTruePart();
+ final PyExpression falsePart = node.getFalsePart();
+ if (truePart != null) {
+ InstructionBuilder.addAssertInstructions(myBuilder, assertionEvaluator);
+ truePart.accept(this);
+ myBuilder.addPendingEdge(node, myBuilder.prevInstruction);
+ }
+ if (falsePart != null) {
+ myBuilder.prevInstruction = branchingPoint;
+ falsePart.accept(this);
+ myBuilder.addPendingEdge(node, myBuilder.prevInstruction);
+ }
+ }
+
@Override
public void visitPyIfStatement(final PyIfStatement node) {
myBuilder.startNode(node);
diff --git a/python/src/com/jetbrains/python/codeInsight/controlflow/PyTypeAssertionEvaluator.java b/python/src/com/jetbrains/python/codeInsight/controlflow/PyTypeAssertionEvaluator.java
index 9dfcfefcd8ce..524d43d46ce4 100644
--- a/python/src/com/jetbrains/python/codeInsight/controlflow/PyTypeAssertionEvaluator.java
+++ b/python/src/com/jetbrains/python/codeInsight/controlflow/PyTypeAssertionEvaluator.java
@@ -50,16 +50,14 @@ public class PyTypeAssertionEvaluator extends PyRecursiveElementVisitor {
final PyReferenceExpression target = (PyReferenceExpression)args[0];
final PyExpression typeElement = args[1];
final boolean positive = myPositive;
- if (!processTuple(target, typeElement)) {
- pushAssertion(target, new InstructionTypeCallback() {
- @Override
- public PyType getType(TypeEvalContext context, PsiElement anchor) {
- final List types = new ArrayList();
- types.add(context.getType(typeElement));
- return createAssertionType(context.getType(target), types, positive, context);
- }
- });
- }
+ pushAssertion(target, new InstructionTypeCallback() {
+ @Override
+ public PyType getType(TypeEvalContext context, PsiElement anchor) {
+ final List types = new ArrayList();
+ types.add(context.getType(typeElement));
+ return createAssertionType(context.getType(target), types, positive, context);
+ }
+ });
}
}
else if (node.isCalleeText(PyNames.CALLABLE_BUILTIN)) {
@@ -120,34 +118,11 @@ public class PyTypeAssertionEvaluator extends PyRecursiveElementVisitor {
super.visitPyBinaryExpression(node);
}
- private boolean processTuple(final PyReferenceExpression target, PyExpression typeElement) {
- boolean pushed = false;
- if (typeElement instanceof PyParenthesizedExpression) {
- final PyExpression contained = ((PyParenthesizedExpression)typeElement).getContainedExpression();
- if (contained instanceof PyTupleExpression) {
- final PyTupleExpression tuple = (PyTupleExpression)contained;
- final boolean positive = myPositive;
- pushAssertion(target, new InstructionTypeCallback() {
- @Override
- public PyType getType(TypeEvalContext context, @Nullable PsiElement anchor) {
- final List types = new ArrayList();
- for (PyExpression e : tuple.getElements()) {
- types.add(context.getType(e));
- }
- return createAssertionType(context.getType(target), types, positive, context);
- }
- });
- pushed = true;
- }
- }
- return pushed;
- }
-
@Nullable
private static PyType createAssertionType(PyType initial, List types, boolean positive, TypeEvalContext context) {
final List members = new ArrayList();
for (PyType t : types) {
- members.add(t instanceof PyClassType ? ((PyClassType)t).toInstance() : t);
+ members.add(transformTypeFromAssertion(t));
}
final PyType union = PyUnionType.union(members);
if (positive) {
@@ -162,6 +137,23 @@ public class PyTypeAssertionEvaluator extends PyRecursiveElementVisitor {
return initial;
}
+ @Nullable
+ private static PyType transformTypeFromAssertion(@Nullable PyType type) {
+ if (type instanceof PyTupleType) {
+ final List members = new ArrayList();
+ final PyTupleType tupleType = (PyTupleType)type;
+ final int count = tupleType.getElementCount();
+ for (int i = 0; i < count; i++) {
+ members.add(transformTypeFromAssertion(tupleType.getElementType(i)));
+ }
+ return PyUnionType.union(members);
+ }
+ else if (type instanceof PyClassType) {
+ return ((PyClassType)type).toInstance();
+ }
+ return type;
+ }
+
private void pushAssertion(PyReferenceExpression element, InstructionTypeCallback getType) {
myStack.push(new Assertion(element, getType));
}
diff --git a/python/src/com/jetbrains/python/console/PydevConsoleRunner.java b/python/src/com/jetbrains/python/console/PydevConsoleRunner.java
index 6ef9e1b93228..7798fcef809d 100644
--- a/python/src/com/jetbrains/python/console/PydevConsoleRunner.java
+++ b/python/src/com/jetbrains/python/console/PydevConsoleRunner.java
@@ -684,26 +684,10 @@ public class PydevConsoleRunner extends AbstractConsoleRunnerWithHistory() {
@Override
public ControlFlowUtil.Operation fun(Instruction instruction) {
- if (instruction.allPred().isEmpty() && instruction.num() != 0) {
+ if (instruction.allPred().isEmpty() && !isFirstInstruction(instruction)) {
unreachable.add(instruction.getElement());
}
return ControlFlowUtil.Operation.NEXT;
@@ -63,4 +65,32 @@ public class PyUnreachableCodeInspection extends PyInspection {
}
}
}
+
+ public static boolean hasAnyInterruptedControlFlowPaths(@NotNull PsiElement element) {
+ final ScopeOwner owner = ScopeUtil.getScopeOwner(element);
+ if (owner != null) {
+ final ControlFlow flow = ControlFlowCache.getControlFlow(owner);
+ final Instruction[] instructions = flow.getInstructions();
+ final int start = ControlFlowUtil.findInstructionNumberByElement(instructions, element);
+ if (start >= 0) {
+ final Ref resultRef = Ref.create(false);
+ ControlFlowUtil.iteratePrev(start, instructions, new Function() {
+ @Override
+ public ControlFlowUtil.Operation fun(Instruction instruction) {
+ if (instruction.allPred().isEmpty() && !isFirstInstruction(instruction)) {
+ resultRef.set(true);
+ return ControlFlowUtil.Operation.BREAK;
+ }
+ return ControlFlowUtil.Operation.NEXT;
+ }
+ });
+ return resultRef.get();
+ }
+ }
+ return false;
+ }
+
+ private static boolean isFirstInstruction(Instruction instruction) {
+ return instruction.num() == 0;
+ }
}
diff --git a/python/src/com/jetbrains/python/inspections/PyUnresolvedReferencesInspection.java b/python/src/com/jetbrains/python/inspections/PyUnresolvedReferencesInspection.java
index 612e165e4ec9..4f7c75af671d 100644
--- a/python/src/com/jetbrains/python/inspections/PyUnresolvedReferencesInspection.java
+++ b/python/src/com/jetbrains/python/inspections/PyUnresolvedReferencesInspection.java
@@ -426,6 +426,9 @@ public class PyUnresolvedReferencesInspection extends PyInspection {
if ((object_type != null) && object_type.getPossibleInstanceMembers().contains(refname)) return;
}
else {
+ if (PyUnreachableCodeInspection.hasAnyInterruptedControlFlowPaths(refex)) {
+ return;
+ }
if (LanguageLevel.forElement(node).isOlderThan(LanguageLevel.PYTHON26)) {
if ("with".equals(refname)) {
actions.add(new UnresolvedRefAddFutureImportQuickFix());
diff --git a/python/testData/codeInsight/controlflow/conditionalexpression.py b/python/testData/codeInsight/controlflow/conditionalexpression.py
new file mode 100644
index 000000000000..9147a26b540c
--- /dev/null
+++ b/python/testData/codeInsight/controlflow/conditionalexpression.py
@@ -0,0 +1,4 @@
+x = 1
+y = 2
+c = True
+z = x if c else y
diff --git a/python/testData/codeInsight/controlflow/conditionalexpression.txt b/python/testData/codeInsight/controlflow/conditionalexpression.txt
new file mode 100644
index 000000000000..49319efc93b2
--- /dev/null
+++ b/python/testData/codeInsight/controlflow/conditionalexpression.txt
@@ -0,0 +1,16 @@
+0(1) element: null
+1(2) element: PyAssignmentStatement
+2(3) WRITE ACCESS: x
+3(4) element: PyAssignmentStatement
+4(5) WRITE ACCESS: y
+5(6) element: PyAssignmentStatement
+6(7) READ ACCESS: True
+7(8) WRITE ACCESS: c
+8(9) element: PyAssignmentStatement
+9(10) element: PyConditionalExpression
+10(11,12) READ ACCESS: c
+11(13) READ ACCESS: x
+12(13) READ ACCESS: y
+13(14) WRITE ACCESS: z
+14() element: null
+
diff --git a/python/testData/inspections/PyUnboundLocalVariableInspection/UnboundUnreachable.py b/python/testData/inspections/PyUnboundLocalVariableInspection/UnboundUnreachable.py
new file mode 100644
index 000000000000..02cc63c063e1
--- /dev/null
+++ b/python/testData/inspections/PyUnboundLocalVariableInspection/UnboundUnreachable.py
@@ -0,0 +1,7 @@
+def test1(c, xs):
+ if c:
+ y = 1
+ print(y)
+ for x in xs:
+ continue
+ z = 1
diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/unresolvedUnreachable.py b/python/testData/inspections/PyUnresolvedReferencesInspection/unresolvedUnreachable.py
new file mode 100644
index 000000000000..e47812f45030
--- /dev/null
+++ b/python/testData/inspections/PyUnresolvedReferencesInspection/unresolvedUnreachable.py
@@ -0,0 +1,5 @@
+def f():
+ x = 1
+ print(z)
+ return x
+ print(x)
diff --git a/python/testSrc/com/jetbrains/python/PyControlFlowBuilderTest.java b/python/testSrc/com/jetbrains/python/PyControlFlowBuilderTest.java
index 09695ea2bcf1..f608c9bca23e 100644
--- a/python/testSrc/com/jetbrains/python/PyControlFlowBuilderTest.java
+++ b/python/testSrc/com/jetbrains/python/PyControlFlowBuilderTest.java
@@ -218,6 +218,10 @@ public class PyControlFlowBuilderTest extends LightMarkedTestCase {
doTest();
}
+ public void testConditionalExpression() {
+ doTest();
+ }
+
private void doTestFirstStatement() {
final String testName = getTestName(false).toLowerCase();
configureByFile(testName + ".py");
diff --git a/python/testSrc/com/jetbrains/python/PyTypeTest.java b/python/testSrc/com/jetbrains/python/PyTypeTest.java
index 04abeabedc45..c5dcfbcd64ea 100644
--- a/python/testSrc/com/jetbrains/python/PyTypeTest.java
+++ b/python/testSrc/com/jetbrains/python/PyTypeTest.java
@@ -737,6 +737,21 @@ public class PyTypeTest extends PyTestCase {
" expr = x\n");
}
+ public void testIsInstanceExpressionResolvedToTuple() {
+ doTest("str | unicode",
+ "string_types = str, unicode\n" +
+ "\n" +
+ "def f(x):\n" +
+ " if isinstance(x, string_types):\n" +
+ " expr = x\n");
+ }
+
+ public void testIsInstanceInConditionalExpression() {
+ doTest("str | int",
+ "def f(x):\n" +
+ " expr = x if isinstance(x, str) else 10\n");
+ }
+
private static TypeEvalContext getTypeEvalContext(@NotNull PyExpression element) {
return TypeEvalContext.userInitiated(element.getContainingFile()).withTracing();
}
diff --git a/python/testSrc/com/jetbrains/python/fixtures/PyTestCase.java b/python/testSrc/com/jetbrains/python/fixtures/PyTestCase.java
index 397b487abd4a..3d70ffcd78ef 100644
--- a/python/testSrc/com/jetbrains/python/fixtures/PyTestCase.java
+++ b/python/testSrc/com/jetbrains/python/fixtures/PyTestCase.java
@@ -147,6 +147,6 @@ public abstract class PyTestCase extends UsefulTestCase {
}
public static void initPlatformPrefix() {
- PlatformTestCase.initPlatformPrefix(IDEA_MARKER_CLASS, PlatformUtils.PYCHARM_PREFIX);
+ PlatformTestCase.initPlatformPrefix(UsefulTestCase.IDEA_MARKER_CLASS, PlatformUtils.PYCHARM_PREFIX);
}
}
diff --git a/python/testSrc/com/jetbrains/python/inspections/PyUnboundLocalVariableInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyUnboundLocalVariableInspectionTest.java
index b46fb6c655fa..3a13ef14c22b 100644
--- a/python/testSrc/com/jetbrains/python/inspections/PyUnboundLocalVariableInspectionTest.java
+++ b/python/testSrc/com/jetbrains/python/inspections/PyUnboundLocalVariableInspectionTest.java
@@ -173,6 +173,11 @@ public class PyUnboundLocalVariableInspectionTest extends PyTestCase {
doTest();
}
+ // PY-6114
+ public void testUnboundUnreachable() {
+ doTest();
+ }
+
private void doTest() {
myFixture.configureByFile(TEST_DIRECTORY + getTestName(false) + ".py");
myFixture.enableInspections(PyUnboundLocalVariableInspection.class);
diff --git a/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java
index 7457bfc70552..3b9c39c548d9 100644
--- a/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java
+++ b/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java
@@ -289,6 +289,11 @@ public class PyUnresolvedReferencesInspectionTest extends PyTestCase {
doTest();
}
+ // PY-10006
+ public void testUnresolvedUnreachable() {
+ doTest();
+ }
+
private void doTest() {
myFixture.configureByFile(TEST_DIRECTORY + getTestName(true) + ".py");
myFixture.enableInspections(PyUnresolvedReferencesInspection.class);
diff --git a/python/testSrc/python-community-tests.iml b/python/testSrc/python-community-tests.iml
new file mode 100644
index 000000000000..38fa516e812e
--- /dev/null
+++ b/python/testSrc/python-community-tests.iml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+