diff --git a/python/python-psi-impl/src/com/jetbrains/python/psi/types/PyTypeChecker.java b/python/python-psi-impl/src/com/jetbrains/python/psi/types/PyTypeChecker.java index 2f5e32da5e03..10432517871a 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/psi/types/PyTypeChecker.java +++ b/python/python-psi-impl/src/com/jetbrains/python/psi/types/PyTypeChecker.java @@ -215,7 +215,7 @@ public class PyTypeChecker { context.substitutions.put(expected, actual); } else if (bound != null) { - context.substitutions.put(expected, bound); + context.substitutions.put(expected, PyUnionType.createWeakType(bound)); } return true; diff --git a/python/testSrc/com/jetbrains/python/PyTypeTest.java b/python/testSrc/com/jetbrains/python/PyTypeTest.java index e1c286f4c2ac..637f4d76f5e5 100644 --- a/python/testSrc/com/jetbrains/python/PyTypeTest.java +++ b/python/testSrc/com/jetbrains/python/PyTypeTest.java @@ -636,7 +636,7 @@ public class PyTypeTest extends PyTestCase { } public void testUpperBoundGeneric() { - doTest("Union[int, str]", + doTest("Union[Union[int, str], Any]", "def foo(x):\n" + " '''\n" + " :type x: T <= int or str\n" + diff --git a/python/testSrc/com/jetbrains/python/PyTypingTest.java b/python/testSrc/com/jetbrains/python/PyTypingTest.java index 1f9608495a03..58af95f1312d 100644 --- a/python/testSrc/com/jetbrains/python/PyTypingTest.java +++ b/python/testSrc/com/jetbrains/python/PyTypingTest.java @@ -239,7 +239,7 @@ public class PyTypingTest extends PyTestCase { } public void testAnyStrForUnknown() { - doTest("Union[str, bytes]", + doTest("Union[Union[str, bytes], Any]", "from typing import AnyStr\n" + "\n" + "def foo(x: AnyStr) -> AnyStr:\n" +