From 03c7843ae3d602cf6ae731a7daaa6020cc2d6150 Mon Sep 17 00:00:00 2001 From: Semyon Proshev Date: Fri, 29 Dec 2017 15:37:44 +0300 Subject: [PATCH] Revert "Special case `typing` for Python < 3.5 (PY-22945)" This reverts commit 891b423d16e1dcac80c626dc7ca49ebe200fabb0. Don't disable resolve to typing because stubs would become useless. --- .../com/jetbrains/python/codeInsight/typing/PyTypeShed.kt | 4 ---- python/testSrc/com/jetbrains/python/PyTypeTest.java | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/python/src/com/jetbrains/python/codeInsight/typing/PyTypeShed.kt b/python/src/com/jetbrains/python/codeInsight/typing/PyTypeShed.kt index 2c2db73c2968..2c4557c4de42 100644 --- a/python/src/com/jetbrains/python/codeInsight/typing/PyTypeShed.kt +++ b/python/src/com/jetbrains/python/codeInsight/typing/PyTypeShed.kt @@ -57,11 +57,7 @@ object PyTypeShed { return false } if (isInStandardLibrary(root)) { - if (ApplicationManager.getApplication().isUnitTestMode || - topLevelPackage != TYPING || - PythonSdkType.getLanguageLevelForSdk(sdk).isAtLeast(LanguageLevel.PYTHON35)) { return true - } } if (isInThirdPartyLibraries(root)) { if (ApplicationManager.getApplication().isUnitTestMode) { diff --git a/python/testSrc/com/jetbrains/python/PyTypeTest.java b/python/testSrc/com/jetbrains/python/PyTypeTest.java index 94f420e5a822..b14e39960b9c 100644 --- a/python/testSrc/com/jetbrains/python/PyTypeTest.java +++ b/python/testSrc/com/jetbrains/python/PyTypeTest.java @@ -2587,6 +2587,13 @@ public class PyTypeTest extends PyTestCase { ); } + // PY-22945 + public void testNotInstalledTypingUsedInAnalysis() { + doTest("Pattern[str]", + "from re import compile\n" + + "expr = compile(\"str\")"); + } + private static List getTypeEvalContexts(@NotNull PyExpression element) { return ImmutableList.of(TypeEvalContext.codeAnalysis(element.getProject(), element.getContainingFile()).withTracing(), TypeEvalContext.userInitiated(element.getProject(), element.getContainingFile()).withTracing());