Don't narrow type variable to its bound if actual type is Any (PY-43027)

GitOrigin-RevId: 7fca22b43203fdfc9fa2e2fa7452e362e6ec8dfd
This commit is contained in:
Semyon Proshev
2020-06-18 00:28:17 +03:00
committed by intellij-monorepo-bot
parent c5a8c9a330
commit 28dfeb83f5
3 changed files with 3 additions and 3 deletions
@@ -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;
@@ -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" +
@@ -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" +