mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-86002 Revert also PY-25989 PY-84544 to fix new test failures after the revert to weak unions
Namely, `generics_basic.py` in the conformance test suite and Py3TypeCheckerInspectionTest.testTypeVarWidening. Revert 07803c6243370d55df0d870e2e32b38170c1fb49 (cherry picked from commit 9c334ef32597be1d1e8fbc3251ac267be46555c8) IJ-MR-184619 GitOrigin-RevId: 4b2440c973d9c7a7a42590665bd473c4e7a4c9cf
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7c1fa29f39
commit
060b900cf9
@@ -3332,33 +3332,4 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
var: Template = Concrete()
|
||||
""");
|
||||
}
|
||||
|
||||
// PY-25989 PY-84544
|
||||
public void testTypeVarWidening() {
|
||||
myFixture.enableInspections(PyAssertTypeInspection.class);
|
||||
doTestByText("""
|
||||
from collections.abc import Iterable
|
||||
from typing import assert_type
|
||||
|
||||
|
||||
# PY-84544
|
||||
def foo(iterable: Iterable[int] | Iterable[str]) -> None:
|
||||
assert_type(next(iter(iterable)), int | str)
|
||||
|
||||
|
||||
# PY-25989
|
||||
assert_type(max(1, 2.6), float)
|
||||
assert_type(max(2.6, 1), float)
|
||||
max(1, <warning descr="Expected type 'int' (matched generic type 'SupportsRichComparisonT ≤: SupportsDunderLT[Any] | SupportsDunderGT[Any]'), got 'object' instead">object()</warning>)
|
||||
|
||||
|
||||
def bar[T: int, str](v1: T, v2: T) -> T:
|
||||
if (bool(input())):
|
||||
return v1
|
||||
return v2
|
||||
|
||||
|
||||
_ = bar(1, <warning descr="Expected type 'int' (matched generic type 'T ≤: int'), got 'str' instead">"a"</warning>)
|
||||
""");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1347,10 +1347,7 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
def accepts_anything(x: str) -> None:
|
||||
pass
|
||||
|
||||
# Bug: Expected error.
|
||||
# `Callable[[str], None]` is assignable to `Callable[[int | str], None]`.
|
||||
# Thus, substitution `T` -> `int | str` is considered valid.
|
||||
func(42, accepts_anything)""")
|
||||
func(42, <warning descr="Expected type '(int) -> None' (matched generic type '(T) -> None'), got '(x: str) -> None' instead">accepts_anything</warning>)""")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user