mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Revert tests with over-inferring LiteralString
(cherry picked from commit 0c92e1c64362e2834b01b4e0bcbcedfefe4febe0) IJ-MR-112631 GitOrigin-RevId: 233abfde16b19e96c5bc39c77eef1a240aa1b3e8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9661b002e0
commit
ad5b55918e
@@ -142,7 +142,7 @@ class PyCodeFenceTest : PyTestCase() {
|
||||
expect_str("abc")
|
||||
|
||||
# Should warn
|
||||
expect_bytes(<warning descr="Expected type 'bytes', got 'LiteralString' instead">"abc"</warning>)
|
||||
expect_bytes(<warning descr="Expected type 'bytes', got 'str' instead">"abc"</warning>)
|
||||
```
|
||||
""".trimIndent())
|
||||
myFixture.enableInspections(PyTypeCheckerInspection::class.java)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
def f():
|
||||
x1: int = <warning descr="Expected type 'int', got 'LiteralString' instead">'foo'</warning>
|
||||
x1: int = <warning descr="Expected type 'int', got 'str' instead">'foo'</warning>
|
||||
x2: str = 'bar'
|
||||
x3: int = 0
|
||||
x4: str = <warning descr="Expected type 'str', got 'int' instead">1</warning>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
def test_operators():
|
||||
print(2 + <warning descr="Expected type 'int', got 'LiteralString' instead">'foo'</warning>)
|
||||
print(b'foo' + <warning descr="Expected type 'bytes', got 'LiteralString' instead">'bar'</warning>)
|
||||
print(2 + <warning descr="Expected type 'int', got 'str' instead">'foo'</warning>)
|
||||
print(b'foo' + <warning descr="Expected type 'bytes', got 'str' instead">'bar'</warning>)
|
||||
print(b'foo' + <warning descr="Expected type 'bytes', got 'int' instead">3</warning>)
|
||||
|
||||
|
||||
@@ -11,6 +11,6 @@ def test_numerics():
|
||||
float(False)
|
||||
complex(False)
|
||||
divmod(False, False)
|
||||
divmod<warning descr="Unexpected type(s):(bytes, LiteralString)Possible type(s):(SupportsDivMod[_T_contra, _T_co], LiteralString)(bytes, SupportsRDivMod[bytes, _T_co])">(b'foo', 'bar')</warning>
|
||||
divmod<warning descr="Unexpected type(s):(bytes, str)Possible type(s):(SupportsDivMod[_T_contra, _T_co], str)(bytes, SupportsRDivMod[bytes, _T_co])">(b'foo', 'bar')</warning>
|
||||
pow(False, True)
|
||||
round<warning descr="Unexpected type(s):(bool, LiteralString)Possible type(s):(SupportsRound, None)(SupportsRound[int], SupportsIndex)">(False, 'foo')</warning>
|
||||
round<warning descr="Unexpected type(s):(bool, str)Possible type(s):(SupportsRound, None)(SupportsRound[int], SupportsIndex)">(False, 'foo')</warning>
|
||||
|
||||
@@ -3,5 +3,5 @@ class Foo:
|
||||
return arg
|
||||
|
||||
bar = Foo()
|
||||
bar.__call__(<warning descr="Expected type 'int', got 'LiteralString' instead">"s"</warning>)
|
||||
bar(<warning descr="Expected type 'int', got 'LiteralString' instead">"s"</warning>)
|
||||
bar.__call__(<warning descr="Expected type 'int', got 'str' instead">"s"</warning>)
|
||||
bar(<warning descr="Expected type 'int', got 'str' instead">"s"</warning>)
|
||||
+1
-1
@@ -11,4 +11,4 @@ class MyClass(Generic[T]):
|
||||
pass
|
||||
|
||||
|
||||
x = MyClass(1) < MyClass(2) < <warning descr="Expected type 'MyClass[int]' (matched generic type 'MyClass[T]'), got 'MyClass[LiteralString]' instead">MyClass('foo')</warning>
|
||||
x = MyClass(1) < MyClass(2) < <warning descr="Expected type 'MyClass[int]' (matched generic type 'MyClass[T]'), got 'MyClass[str]' instead">MyClass('foo')</warning>
|
||||
|
||||
@@ -9,13 +9,13 @@ class C:
|
||||
|
||||
def f(self):
|
||||
self.x = 1
|
||||
self.x = <warning descr="Expected type 'int', got 'LiteralString' instead">'bar'</warning>
|
||||
self.x = <warning descr="Expected type 'int', got 'str' instead">'bar'</warning>
|
||||
self.y = 1
|
||||
self.y = <warning descr="Expected type 'int', got 'LiteralString' instead">'bar'</warning>
|
||||
self.y = <warning descr="Expected type 'int', got 'str' instead">'bar'</warning>
|
||||
self.z = 1
|
||||
self.z = <warning descr="Expected type 'int', got 'LiteralString' instead">'bar'</warning>
|
||||
self.z = <warning descr="Expected type 'int', got 'str' instead">'bar'</warning>
|
||||
|
||||
self.class_var = 1
|
||||
self.class_var = <warning descr="Expected type 'int', got 'LiteralString' instead">'bar'</warning>
|
||||
self.class_var = <warning descr="Expected type 'int', got 'str' instead">'bar'</warning>
|
||||
C.class_var = 1
|
||||
C.class_var = 'bar'
|
||||
|
||||
@@ -9,7 +9,7 @@ class A:
|
||||
|
||||
replace(A(1))
|
||||
replace(A(1), a=1, b="abc")
|
||||
replace(A(1), <warning descr="Expected type 'int', got 'LiteralString' instead">a="str"</warning>, <warning descr="Expected type 'str', got 'int' instead">b=1</warning>)
|
||||
replace(A(1), <warning descr="Expected type 'int', got 'str' instead">a="str"</warning>, <warning descr="Expected type 'str', got 'int' instead">b=1</warning>)
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -20,7 +20,7 @@ class B:
|
||||
|
||||
replace(B(1))
|
||||
replace(B(1), a=1)
|
||||
replace(B(1), <warning descr="Expected type 'int', got 'LiteralString' instead">a="str"</warning>)
|
||||
replace(B(1), <warning descr="Expected type 'int', got 'str' instead">a="str"</warning>)
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -31,7 +31,7 @@ class C:
|
||||
|
||||
replace(C(1))
|
||||
replace(C(1), a=1, b="str")
|
||||
replace(C(1), <warning descr="Expected type 'int', got 'LiteralString' instead">a="str"</warning>, <warning descr="Expected type 'str', got 'int' instead">b=1</warning>)
|
||||
replace(C(1), <warning descr="Expected type 'int', got 'str' instead">a="str"</warning>, <warning descr="Expected type 'str', got 'int' instead">b=1</warning>)
|
||||
|
||||
|
||||
class D:
|
||||
|
||||
@@ -8,4 +8,4 @@ def f(x: int) -> int:
|
||||
|
||||
|
||||
def test():
|
||||
return f(<warning descr="Expected type 'int', got 'LiteralString' instead">(yield from a())</warning>)
|
||||
return f(<warning descr="Expected type 'int', got 'str' instead">(yield from a())</warning>)
|
||||
@@ -7,7 +7,7 @@ def b(x: int) -> List[str]:
|
||||
return <warning descr="Expected type 'list[str]', got 'list[int]' instead">[1,2]</warning>
|
||||
|
||||
def c() -> int:
|
||||
return <warning descr="Expected type 'int', got 'LiteralString' instead">'abc'</warning>
|
||||
return <warning descr="Expected type 'int', got 'str' instead">'abc'</warning>
|
||||
|
||||
def d(x: int) -> List[str]:
|
||||
return [str(x)]
|
||||
@@ -26,7 +26,7 @@ def f() -> Optional[str]:
|
||||
|
||||
def g(x) -> int:
|
||||
if x:
|
||||
return <warning descr="Expected type 'int', got 'LiteralString' instead">'abc'</warning>
|
||||
return <warning descr="Expected type 'int', got 'str' instead">'abc'</warning>
|
||||
else:
|
||||
return <warning descr="Expected type 'int', got 'dict' instead">{}</warning>
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ int_and_bool = (42, True)
|
||||
expects_many_ints(int_and_bool)
|
||||
|
||||
int_and_str = (42, 'foo')
|
||||
expects_many_ints(<warning descr="Expected type 'tuple[int, ...]', got 'tuple[int, LiteralString]' instead">int_and_str</warning>)
|
||||
expects_many_ints(<warning descr="Expected type 'tuple[int, ...]', got 'tuple[int, str]' instead">int_and_str</warning>)
|
||||
|
||||
booleans = (True, False) # type: Tuple[bool, ...]
|
||||
expects_many_ints(booleans)
|
||||
|
||||
@@ -8,10 +8,10 @@ class A:
|
||||
z: float = 0.0
|
||||
|
||||
A(1, "a")
|
||||
A(<warning descr="Expected type 'int', got 'LiteralString' instead">"a"</warning>, <warning descr="Expected type 'str', got 'int' instead">1</warning>)
|
||||
A(<warning descr="Expected type 'int', got 'str' instead">"a"</warning>, <warning descr="Expected type 'str', got 'int' instead">1</warning>)
|
||||
|
||||
A(1, "a", 1.0)
|
||||
A(<warning descr="Expected type 'int', got 'LiteralString' instead">"a"</warning>, <warning descr="Expected type 'str', got 'int' instead">1</warning>, <warning descr="Expected type 'float', got 'LiteralString' instead">"b"</warning>)
|
||||
A(<warning descr="Expected type 'int', got 'str' instead">"a"</warning>, <warning descr="Expected type 'str', got 'int' instead">1</warning>, <warning descr="Expected type 'float', got 'str' instead">"b"</warning>)
|
||||
|
||||
|
||||
@dataclasses.dataclass(init=True)
|
||||
@@ -21,10 +21,10 @@ class A2:
|
||||
z: float = 0.0
|
||||
|
||||
A2(1, "a")
|
||||
A2(<warning descr="Expected type 'int', got 'LiteralString' instead">"a"</warning>, <warning descr="Expected type 'str', got 'int' instead">1</warning>)
|
||||
A2(<warning descr="Expected type 'int', got 'str' instead">"a"</warning>, <warning descr="Expected type 'str', got 'int' instead">1</warning>)
|
||||
|
||||
A2(1, "a", 1.0)
|
||||
A2(<warning descr="Expected type 'int', got 'LiteralString' instead">"a"</warning>, <warning descr="Expected type 'str', got 'int' instead">1</warning>, <warning descr="Expected type 'float', got 'LiteralString' instead">"b"</warning>)
|
||||
A2(<warning descr="Expected type 'int', got 'str' instead">"a"</warning>, <warning descr="Expected type 'str', got 'int' instead">1</warning>, <warning descr="Expected type 'float', got 'str' instead">"b"</warning>)
|
||||
|
||||
|
||||
@dataclasses.dataclass(init=False)
|
||||
@@ -55,7 +55,7 @@ class B2:
|
||||
self.z = 0.0
|
||||
|
||||
B2(1)
|
||||
B2(<warning descr="Expected type 'int', got 'LiteralString' instead">"1"</warning>)
|
||||
B2(<warning descr="Expected type 'int', got 'str' instead">"1"</warning>)
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
@@ -64,7 +64,7 @@ class C1:
|
||||
b: int
|
||||
|
||||
C1(1)
|
||||
C1(<warning descr="Expected type 'int', got 'LiteralString' instead">"1"</warning>)
|
||||
C1(<warning descr="Expected type 'int', got 'str' instead">"1"</warning>)
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
@@ -73,7 +73,7 @@ class C2:
|
||||
b: int
|
||||
|
||||
C2(1)
|
||||
C2(<warning descr="Expected type 'int', got 'LiteralString' instead">"1"</warning>)
|
||||
C2(<warning descr="Expected type 'int', got 'str' instead">"1"</warning>)
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
@@ -82,7 +82,7 @@ class D1:
|
||||
b: int
|
||||
|
||||
D1(1, 2)
|
||||
D1(<warning descr="Expected type 'int', got 'LiteralString' instead">"1"</warning>, <warning descr="Expected type 'int', got 'LiteralString' instead">"2"</warning>)
|
||||
D1(<warning descr="Expected type 'int', got 'str' instead">"1"</warning>, <warning descr="Expected type 'int', got 'str' instead">"2"</warning>)
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
@@ -94,13 +94,13 @@ class E1:
|
||||
e: int = dataclasses.field(default_factory=int)
|
||||
|
||||
E1(1, "1")
|
||||
E1(<warning descr="Expected type 'int', got 'LiteralString' instead">"1"</warning>, <warning descr="Expected type 'str', got 'int' instead">1</warning>)
|
||||
E1(<warning descr="Expected type 'int', got 'str' instead">"1"</warning>, <warning descr="Expected type 'str', got 'int' instead">1</warning>)
|
||||
|
||||
E1(1, "1", b"1")
|
||||
E1(<warning descr="Expected type 'int', got 'bytes' instead">b"1"</warning>, "1", <warning descr="Expected type 'bytes', got 'int' instead">1</warning>)
|
||||
|
||||
E1(1, "1", b"1", 1)
|
||||
E1(<warning descr="Expected type 'int', got 'LiteralString' instead">"1"</warning>, <warning descr="Expected type 'str', got 'bytes' instead">b"1"</warning>, <warning descr="Expected type 'bytes', got 'LiteralString' instead">"1"</warning>, <warning descr="Expected type 'int', got 'LiteralString' instead">"1"</warning>)
|
||||
E1(<warning descr="Expected type 'int', got 'str' instead">"1"</warning>, <warning descr="Expected type 'str', got 'bytes' instead">b"1"</warning>, <warning descr="Expected type 'bytes', got 'str' instead">"1"</warning>, <warning descr="Expected type 'int', got 'str' instead">"1"</warning>)
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
|
||||
@@ -3,10 +3,10 @@ from typing import NewType, Dict
|
||||
UserId = NewType("UserId", int)
|
||||
|
||||
a = UserId(42)
|
||||
b = UserId(<warning descr="Expected type 'int', got 'LiteralString' instead">"John"</warning>)
|
||||
b = UserId(<warning descr="Expected type 'int', got 'str' instead">"John"</warning>)
|
||||
|
||||
KeyValue = NewType("KeyValue", Dict[str, int])
|
||||
|
||||
KeyValue({"key": 13})
|
||||
KeyValue(<warning descr="Expected type 'dict[str, int]', got 'int' instead">42</warning>)
|
||||
KeyValue(<warning descr="Expected type 'dict[str, int]', got 'dict[LiteralString, LiteralString]' instead">{"key1": "key2"}</warning>)
|
||||
KeyValue(<warning descr="Expected type 'dict[str, int]', got 'dict[str, str]' instead">{"key1": "key2"}</warning>)
|
||||
|
||||
+16
-16
@@ -27,9 +27,9 @@ MyTup7 = typing.NamedTuple("MyTup7", names=List[str], ages=List[int])
|
||||
|
||||
|
||||
# fail
|
||||
MyTup2(<warning descr="Expected type 'int', got 'LiteralString' instead">''</warning>, '')
|
||||
MyTup2(<warning descr="Expected type 'int', got 'LiteralString' instead">bar=''</warning>, baz='')
|
||||
MyTup2(baz='', <warning descr="Expected type 'int', got 'LiteralString' instead">bar=''</warning>)
|
||||
MyTup2(<warning descr="Expected type 'int', got 'str' instead">''</warning>, '')
|
||||
MyTup2(<warning descr="Expected type 'int', got 'str' instead">bar=''</warning>, baz='')
|
||||
MyTup2(baz='', <warning descr="Expected type 'int', got 'str' instead">bar=''</warning>)
|
||||
|
||||
|
||||
# ok
|
||||
@@ -39,9 +39,9 @@ MyTup2(baz='', bar=5)
|
||||
|
||||
|
||||
# fail
|
||||
MyTup3(<warning descr="Expected type 'int', got 'LiteralString' instead">''</warning>, '')
|
||||
MyTup3(<warning descr="Expected type 'int', got 'LiteralString' instead">bar=''</warning>, baz='')
|
||||
MyTup3(baz='', <warning descr="Expected type 'int', got 'LiteralString' instead">bar=''</warning>)
|
||||
MyTup3(<warning descr="Expected type 'int', got 'str' instead">''</warning>, '')
|
||||
MyTup3(<warning descr="Expected type 'int', got 'str' instead">bar=''</warning>, baz='')
|
||||
MyTup3(baz='', <warning descr="Expected type 'int', got 'str' instead">bar=''</warning>)
|
||||
|
||||
|
||||
# ok
|
||||
@@ -51,9 +51,9 @@ MyTup3(baz='', bar=5)
|
||||
|
||||
|
||||
# fail
|
||||
MyTup4(<warning descr="Expected type 'int', got 'LiteralString' instead">''</warning>, '')
|
||||
MyTup4(<warning descr="Expected type 'int', got 'LiteralString' instead">bar=''</warning>, baz='')
|
||||
MyTup4(baz='', <warning descr="Expected type 'int', got 'LiteralString' instead">bar=''</warning>)
|
||||
MyTup4(<warning descr="Expected type 'int', got 'str' instead">''</warning>, '')
|
||||
MyTup4(<warning descr="Expected type 'int', got 'str' instead">bar=''</warning>, baz='')
|
||||
MyTup4(baz='', <warning descr="Expected type 'int', got 'str' instead">bar=''</warning>)
|
||||
|
||||
|
||||
# ok
|
||||
@@ -63,9 +63,9 @@ MyTup4(baz='', bar=5)
|
||||
|
||||
|
||||
# fail
|
||||
MyTup5(<warning descr="Expected type 'int', got 'LiteralString' instead">''</warning>, '')
|
||||
MyTup5(<warning descr="Expected type 'int', got 'LiteralString' instead">bar=''</warning>, baz='')
|
||||
MyTup5(baz='', <warning descr="Expected type 'int', got 'LiteralString' instead">bar=''</warning>)
|
||||
MyTup5(<warning descr="Expected type 'int', got 'str' instead">''</warning>, '')
|
||||
MyTup5(<warning descr="Expected type 'int', got 'str' instead">bar=''</warning>, baz='')
|
||||
MyTup5(baz='', <warning descr="Expected type 'int', got 'str' instead">bar=''</warning>)
|
||||
|
||||
|
||||
# ok
|
||||
@@ -75,8 +75,8 @@ MyTup5(baz='', bar=5)
|
||||
|
||||
|
||||
# fail
|
||||
MyTup6(<warning descr="Expected type 'int', got 'LiteralString' instead">bar=''</warning>, baz='', <warning descr="Expected type 'int', got 'LiteralString' instead">foo=''</warning>)
|
||||
MyTup6(<warning descr="Expected type 'int', got 'LiteralString' instead">''</warning>, '', <warning descr="Expected type 'int', got 'LiteralString' instead">''</warning>)
|
||||
MyTup6(<warning descr="Expected type 'int', got 'str' instead">bar=''</warning>, baz='', <warning descr="Expected type 'int', got 'str' instead">foo=''</warning>)
|
||||
MyTup6(<warning descr="Expected type 'int', got 'str' instead">''</warning>, '', <warning descr="Expected type 'int', got 'str' instead">''</warning>)
|
||||
|
||||
|
||||
# ok
|
||||
@@ -85,8 +85,8 @@ MyTup6(5, '', 5)
|
||||
|
||||
|
||||
# fail
|
||||
MyTup7(<warning descr="Expected type 'list[str]', got 'LiteralString' instead">names="A"</warning>, <warning descr="Expected type 'list[int]', got 'int' instead">ages=5</warning>)
|
||||
MyTup7(<warning descr="Expected type 'list[str]', got 'LiteralString' instead">"A"</warning>, <warning descr="Expected type 'list[int]', got 'int' instead">5</warning>)
|
||||
MyTup7(<warning descr="Expected type 'list[str]', got 'str' instead">names="A"</warning>, <warning descr="Expected type 'list[int]', got 'int' instead">ages=5</warning>)
|
||||
MyTup7(<warning descr="Expected type 'list[str]', got 'str' instead">"A"</warning>, <warning descr="Expected type 'list[int]', got 'int' instead">5</warning>)
|
||||
|
||||
|
||||
# ok
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
map(<warning descr="Expected type '(_T1) -> _S', got 'LiteralString' instead">'foo'</warning>, <warning descr="Expected type 'Iterable[_T1]', got '(c: Any) -> int' instead">lambda c: 42</warning>)
|
||||
map(<warning descr="Expected type '(_T1) -> _S', got 'str' instead">'foo'</warning>, <warning descr="Expected type 'Iterable[_T1]', got '(c: Any) -> int' instead">lambda c: 42</warning>)
|
||||
|
||||
@@ -7,5 +7,5 @@ def get_user(user: UserId) -> str:
|
||||
|
||||
|
||||
get_user(UserId(5))
|
||||
get_user(<warning descr="Expected type 'UserId', got 'LiteralString' instead">"John"</warning>)
|
||||
get_user(<warning descr="Expected type 'UserId', got 'str' instead">"John"</warning>)
|
||||
get_user(<warning descr="Expected type 'UserId', got 'int' instead">4</warning>)
|
||||
+1
-1
@@ -8,4 +8,4 @@ def expects_int_subclass_or_none(x: Optional[T]):
|
||||
pass
|
||||
|
||||
|
||||
expects_int_subclass_or_none(<warning descr="Expected type 'T | None', got 'LiteralString' instead">'foo'</warning>)
|
||||
expects_int_subclass_or_none(<warning descr="Expected type 'T | None', got 'str' instead">'foo'</warning>)
|
||||
+10
-10
@@ -3,49 +3,49 @@ from typing import Dict, FrozenSet, List, Set, Tuple
|
||||
|
||||
def expects_builtin_list(xs: list[int]):
|
||||
expects_typing_List(xs)
|
||||
expects_typing_List(<warning descr="Expected type 'list[int]', got 'list[LiteralString]' instead">['a']</warning>)
|
||||
expects_typing_List(<warning descr="Expected type 'list[int]', got 'list[str]' instead">['a']</warning>)
|
||||
|
||||
|
||||
def expects_typing_List(xs: List[int]):
|
||||
expects_builtin_list(xs)
|
||||
expects_builtin_list(<warning descr="Expected type 'list[int]', got 'list[LiteralString]' instead">['a']</warning>)
|
||||
expects_builtin_list(<warning descr="Expected type 'list[int]', got 'list[str]' instead">['a']</warning>)
|
||||
|
||||
|
||||
def expects_builtin_set(xs: set[int]):
|
||||
expects_typing_Set(xs)
|
||||
expects_typing_Set(<warning descr="Expected type 'set[int]', got 'set[LiteralString]' instead">{'a'}</warning>)
|
||||
expects_typing_Set(<warning descr="Expected type 'set[int]', got 'set[str]' instead">{'a'}</warning>)
|
||||
|
||||
|
||||
def expects_typing_Set(xs: Set[int]):
|
||||
expects_builtin_set(xs)
|
||||
expects_builtin_set(<warning descr="Expected type 'set[int]', got 'set[LiteralString]' instead">{'a'}</warning>)
|
||||
expects_builtin_set(<warning descr="Expected type 'set[int]', got 'set[str]' instead">{'a'}</warning>)
|
||||
|
||||
|
||||
def expects_builtin_frozenset(xs: frozenset[int]):
|
||||
expects_typing_FrozenSet(xs)
|
||||
expects_typing_FrozenSet(<warning descr="Expected type 'frozenset[int]', got 'frozenset[LiteralString]' instead">frozenset(['a'])</warning>)
|
||||
expects_typing_FrozenSet(<warning descr="Expected type 'frozenset[int]', got 'frozenset[str]' instead">frozenset(['a'])</warning>)
|
||||
|
||||
|
||||
def expects_typing_FrozenSet(xs: FrozenSet[int]):
|
||||
expects_builtin_frozenset(xs)
|
||||
expects_builtin_frozenset(<warning descr="Expected type 'frozenset[int]', got 'frozenset[LiteralString]' instead">frozenset(['a'])</warning>)
|
||||
expects_builtin_frozenset(<warning descr="Expected type 'frozenset[int]', got 'frozenset[str]' instead">frozenset(['a'])</warning>)
|
||||
|
||||
|
||||
def expects_builtin_dict(xs: dict[str, int]):
|
||||
expects_typing_Dict(xs)
|
||||
expects_typing_Dict(<warning descr="Expected type 'dict[str, int]', got 'dict[int, LiteralString]' instead">{42: 'a'}</warning>)
|
||||
expects_typing_Dict(<warning descr="Expected type 'dict[str, int]', got 'dict[int, str]' instead">{42: 'a'}</warning>)
|
||||
|
||||
|
||||
def expects_typing_Dict(xs: Dict[str, int]):
|
||||
expects_builtin_dict(xs)
|
||||
expects_builtin_dict(<warning descr="Expected type 'dict[str, int]', got 'dict[int, LiteralString]' instead">{42: 'a'}</warning>)
|
||||
expects_builtin_dict(<warning descr="Expected type 'dict[str, int]', got 'dict[int, str]' instead">{42: 'a'}</warning>)
|
||||
|
||||
|
||||
def expects_builtin_tuple(xs: tuple[str, int]):
|
||||
expects_typing_Tuple(xs)
|
||||
expects_typing_Tuple(<warning descr="Expected type 'tuple[str, int]', got 'tuple[int, LiteralString]' instead">(42, 'a')</warning>)
|
||||
expects_typing_Tuple(<warning descr="Expected type 'tuple[str, int]', got 'tuple[int, str]' instead">(42, 'a')</warning>)
|
||||
|
||||
|
||||
def expects_typing_Tuple(xs: Tuple[str, int]):
|
||||
expects_builtin_tuple(xs)
|
||||
expects_builtin_tuple(<warning descr="Expected type 'tuple[str, int]', got 'tuple[int, LiteralString]' instead">(42, 'a')</warning>)
|
||||
expects_builtin_tuple(<warning descr="Expected type 'tuple[str, int]', got 'tuple[int, str]' instead">(42, 'a')</warning>)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
def f():
|
||||
x: int = 0
|
||||
x = <warning descr="Expected type 'int', got 'LiteralString' instead">'foo'</warning>
|
||||
x = <warning descr="Expected type 'int', got 'str' instead">'foo'</warning>
|
||||
x = 1
|
||||
x = <warning descr="Expected type 'int', got 'LiteralString' instead">'bar'</warning>
|
||||
x = <warning descr="Expected type 'int', got 'str' instead">'bar'</warning>
|
||||
y: str = 'foo'
|
||||
y = 'bar'
|
||||
y = <warning descr="Expected type 'str', got 'int' instead">0</warning>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from struct import Struct
|
||||
|
||||
s = Struct('c')
|
||||
s.unpack(<warning descr="Expected type 'bytes', got 'LiteralString' instead">'\x00'</warning>)
|
||||
s.unpack(<warning descr="Expected type 'bytes', got 'str' instead">'\x00'</warning>)
|
||||
s.unpack(b'\x00')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
def f():
|
||||
x: int
|
||||
x = <warning descr="Expected type 'int', got 'LiteralString' instead">'foo'</warning>
|
||||
x = <warning descr="Expected type 'int', got 'str' instead">'foo'</warning>
|
||||
y: str
|
||||
y = 'bar'
|
||||
|
||||
@@ -13,7 +13,7 @@ def b(x: int) -> Point:
|
||||
return <warning descr="TypedDict 'Point' has missing key: 'y'">{'x': 42}</warning>
|
||||
|
||||
def c() -> Point:
|
||||
return {'x': <warning descr="Expected type 'int', got 'LiteralString' instead">'abc'</warning>, 'y': 42}
|
||||
return {'x': <warning descr="Expected type 'int', got 'str' instead">'abc'</warning>, 'y': 42}
|
||||
|
||||
def d() -> Point:
|
||||
return {'x': 42, 'y': 42, <warning descr="Extra key 'k' for TypedDict 'Point'">'k': 42</warning>}
|
||||
@@ -22,7 +22,7 @@ def e1(x: int):
|
||||
return {'x': x}
|
||||
|
||||
def e(x: int) -> Point:
|
||||
return <warning descr="Expected type 'Point', got 'dict[LiteralString, int]' instead">e1(x)</warning>
|
||||
return <warning descr="Expected type 'Point', got 'dict[str, int]' instead">e1(x)</warning>
|
||||
|
||||
def f1(x: int) -> Point:
|
||||
pass
|
||||
@@ -34,7 +34,7 @@ def g() -> Point:
|
||||
x = int(input())
|
||||
y = {'x': x}
|
||||
if x > 0:
|
||||
return <warning descr="Expected type 'Point', got 'dict[LiteralString, int]' instead">y</warning>
|
||||
return <warning descr="Expected type 'Point', got 'dict[str, int]' instead">y</warning>
|
||||
elif x == 0:
|
||||
return Point(x=442, y=42)
|
||||
else:
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
avrora = {'name': 'Iskra', 'id': 42}
|
||||
rodina = {'name': 'Iskra'}
|
||||
luksor = {'name': 'Iskra', 'id': <warning descr="Expected type 'int', got 'LiteralString' instead">'42'</warning>}
|
||||
luksor = {'name': 'Iskra', 'id': <warning descr="Expected type 'int', got 'str' instead">'42'</warning>}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
from annotated import A
|
||||
|
||||
|
||||
a: A = <warning descr="Expected type 'int', got 'LiteralString' instead">'str'</warning>
|
||||
a: A = <warning descr="Expected type 'int', got 'str' instead">'str'</warning>
|
||||
a1: A = 42
|
||||
|
||||
@@ -28,5 +28,5 @@ cllbl_b(1, "2")
|
||||
cllbl_c = baz()
|
||||
cllbl_c(1, "2")
|
||||
cllbl_c(1, <warning descr="Expected type 'str', got 'int' instead">2</warning>)
|
||||
cllbl_c(<warning descr="Expected type 'int', got 'LiteralString' instead">"1"</warning>, "2")
|
||||
cllbl_c(<warning descr="Expected type 'int', got 'str' instead">"1"</warning>, "2")
|
||||
cllbl_c(<warning descr="Expected type 'int', got 'list' instead">[]</warning>, <warning descr="Expected type 'str', got 'list' instead">[]</warning>)
|
||||
|
||||
+1
-1
@@ -3,4 +3,4 @@ from required import A, AlternativeSyntax
|
||||
|
||||
a: A = <warning descr="TypedDict 'A' has missing keys: 'x', 'y'">{}</warning>
|
||||
a1: A = {'x': 42, 'y': 42}
|
||||
a2: AlternativeSyntax = {'y': <warning descr="Expected type 'int', got 'LiteralString' instead">"str"</warning>}
|
||||
a2: AlternativeSyntax = {'y': <warning descr="Expected type 'int', got 'str' instead">"str"</warning>}
|
||||
|
||||
+1
-1
@@ -8,4 +8,4 @@ def calc(a: T, b: T):
|
||||
pass
|
||||
|
||||
|
||||
calc('a', <warning descr="Expected type 'LiteralString' (matched generic type 'T'), got 'int' instead">0</warning>)
|
||||
calc('a', <warning descr="Expected type 'str' (matched generic type 'T'), got 'int' instead">0</warning>)
|
||||
|
||||
@@ -2,4 +2,4 @@ with open('foo', 'wb') as fd:
|
||||
fd.write(b'bar')
|
||||
|
||||
with open('foo', 'wb') as fd:
|
||||
fd.write(<warning descr="Expected type 'bytes' (matched generic type 'AnyStr'), got 'LiteralString' instead">'bar'</warning>)
|
||||
fd.write(<warning descr="Expected type 'bytes' (matched generic type 'AnyStr'), got 'str' instead">'bar'</warning>)
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ class C:
|
||||
# Instance level
|
||||
c = C()
|
||||
c.foo.upper()
|
||||
c.foo.<warning descr="Unresolved attribute reference 'non_existent' for class 'LiteralString'">non_existent</warning>()
|
||||
c.foo.<warning descr="Unresolved attribute reference 'non_existent' for class 'str'">non_existent</warning>()
|
||||
c.bar.upper()
|
||||
c.bar.non_existent()
|
||||
c.baz.append()
|
||||
@@ -34,6 +34,6 @@ c.baz.<warning descr="Unresolved attribute reference 'non_existent' for class 'l
|
||||
|
||||
# Class level
|
||||
C.foo.upper()
|
||||
C.foo.<warning descr="Unresolved attribute reference 'non_existent' for class 'LiteralString'">non_existent</warning>()
|
||||
C.foo.<warning descr="Unresolved attribute reference 'non_existent' for class 'str'">non_existent</warning>()
|
||||
C.bar.upper()
|
||||
C.bar.non_existent()
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
from typing import Dict, LiteralString, Any
|
||||
from typing import Dict, Any
|
||||
|
||||
|
||||
def func(x):
|
||||
var: [Dict[LiteralString, Any]] = {'foo': x}
|
||||
var: [Dict[str, Any]] = {'foo': x}
|
||||
var
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
from typing import Union, LiteralString
|
||||
from typing import Union
|
||||
|
||||
from lib import foo
|
||||
|
||||
|
||||
def func():
|
||||
var: [Union[LiteralString, int]] = foo
|
||||
var: [Union[str, int]] = foo
|
||||
var
|
||||
+1
-4
@@ -1,7 +1,4 @@
|
||||
from typing import LiteralString
|
||||
|
||||
|
||||
def func():
|
||||
var: [LiteralString]
|
||||
var: [str]
|
||||
var = another = 'spam'
|
||||
var
|
||||
-3
@@ -1,6 +1,3 @@
|
||||
from typing import LiteralString
|
||||
|
||||
|
||||
def func():
|
||||
var: [LiteralString]
|
||||
for var in 'spam':
|
||||
|
||||
+1
-4
@@ -1,6 +1,3 @@
|
||||
from typing import LiteralString
|
||||
|
||||
|
||||
def func():
|
||||
var: [LiteralString] = 'spam'
|
||||
var: [str] = 'spam'
|
||||
var
|
||||
|
||||
+1
-4
@@ -1,7 +1,4 @@
|
||||
from typing import LiteralString
|
||||
|
||||
|
||||
def func():
|
||||
var: [LiteralString]
|
||||
var: [str]
|
||||
var, _ = 'spam', 42
|
||||
var
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
from typing import Tuple, LiteralString
|
||||
from typing import Tuple
|
||||
|
||||
var: [Tuple[int, LiteralString, None]] = (1, 'foo', None)
|
||||
var: [Tuple[int, str, None]] = (1, 'foo', None)
|
||||
@@ -1,6 +1,6 @@
|
||||
from m1 import g, Gen
|
||||
|
||||
g(<warning descr="Expected type 'dict', got 'int' instead">Gen(10).get(10, 10)</warning>)
|
||||
g(Gen(10).get<warning descr="Unexpected type(s):(int, LiteralString)Possible type(s):(int, int)(str, int)">(10, 'foo')</warning>)
|
||||
g(Gen('foo').get<warning descr="Unexpected type(s):(int, int)Possible type(s):(int, LiteralString)(str, LiteralString)">(10, 10)</warning>)
|
||||
g(<warning descr="Expected type 'dict', got 'LiteralString' instead">Gen('foo').get(10, 'foo')</warning>)
|
||||
g(Gen(10).get<warning descr="Unexpected type(s):(int, str)Possible type(s):(int, int)(str, int)">(10, 'foo')</warning>)
|
||||
g(Gen('foo').get<warning descr="Unexpected type(s):(int, int)Possible type(s):(int, str)(str, str)">(10, 10)</warning>)
|
||||
g(<warning descr="Expected type 'dict', got 'str' instead">Gen('foo').get(10, 'foo')</warning>)
|
||||
|
||||
+8
-8
@@ -3,26 +3,26 @@ from m1 import f, g, h
|
||||
|
||||
def test_different_number_of_parameters():
|
||||
f(5)
|
||||
f(<warning descr="Expected type 'int', got 'LiteralString' instead">"a"</warning>)
|
||||
f(<warning descr="Expected type 'int', got 'str' instead">"a"</warning>)
|
||||
|
||||
f(5, "a")
|
||||
f(<warning descr="Expected type 'int', got 'LiteralString' instead">"a"</warning>, "b")
|
||||
f(<warning descr="Expected type 'int', got 'str' instead">"a"</warning>, "b")
|
||||
f(5, <warning descr="Expected type 'str', got 'int' instead">6</warning>)
|
||||
f(<warning descr="Expected type 'int', got 'LiteralString' instead">"a"</warning>, <warning descr="Expected type 'str', got 'int' instead">5</warning>)
|
||||
f(<warning descr="Expected type 'int', got 'str' instead">"a"</warning>, <warning descr="Expected type 'str', got 'int' instead">5</warning>)
|
||||
|
||||
|
||||
def test_same_number_of_parameters_but_one_is_default():
|
||||
g(5)
|
||||
g(<warning descr="Expected type 'int', got 'LiteralString' instead">"a"</warning>)
|
||||
g(<warning descr="Expected type 'int', got 'str' instead">"a"</warning>)
|
||||
|
||||
g<warning descr="Unexpected type(s):(LiteralString, bool)Possible type(s):(int, bool)(int, str)">("a", False)</warning>
|
||||
g<warning descr="Unexpected type(s):(str, bool)Possible type(s):(int, bool)(int, str)">("a", False)</warning>
|
||||
g<warning descr="Unexpected type(s):(int, int)Possible type(s):(int, bool)(int, str)">(5, 6)</warning>
|
||||
g<warning descr="Unexpected type(s):(bool, int)Possible type(s):(int, bool)(int, str)">(False, 5)</warning>
|
||||
|
||||
g(5, "a")
|
||||
g<warning descr="Unexpected type(s):(LiteralString, LiteralString)Possible type(s):(int, bool)(int, str)">("a", "b")</warning>
|
||||
g<warning descr="Unexpected type(s):(str, str)Possible type(s):(int, bool)(int, str)">("a", "b")</warning>
|
||||
g<warning descr="Unexpected type(s):(int, int)Possible type(s):(int, bool)(int, str)">(5, 6)</warning>
|
||||
g<warning descr="Unexpected type(s):(LiteralString, int)Possible type(s):(int, bool)(int, str)">("a", 5)</warning>
|
||||
g<warning descr="Unexpected type(s):(str, int)Possible type(s):(int, bool)(int, str)">("a", 5)</warning>
|
||||
|
||||
|
||||
def test_different_number_of_parameters_one_is_default():
|
||||
@@ -34,4 +34,4 @@ def test_different_number_of_parameters_one_is_default():
|
||||
h("a", False)
|
||||
h(<warning descr="Expected type 'str', got 'int' instead">5</warning>, False) # fail
|
||||
h("a", <warning descr="Expected type 'bool', got 'int' instead">5</warning>) # fail
|
||||
h(<warning descr="Expected type 'str', got 'bool' instead">False</warning>, <warning descr="Expected type 'bool', got 'LiteralString' instead">"a"</warning>) # fail
|
||||
h(<warning descr="Expected type 'str', got 'bool' instead">False</warning>, <warning descr="Expected type 'bool', got 'str' instead">"a"</warning>) # fail
|
||||
@@ -3,4 +3,4 @@ class A():
|
||||
x = ""
|
||||
|
||||
|
||||
b = <warning descr="'LiteralString' object is not callable">A().<caret>x()</warning>
|
||||
b = <warning descr="'str' object is not callable">A().<caret>x()</warning>
|
||||
@@ -5,7 +5,7 @@ def b(c):
|
||||
pass
|
||||
|
||||
|
||||
<warning descr="'LiteralString' object is not callable">@<caret>a</warning>
|
||||
<warning descr="'str' object is not callable">@<caret>a</warning>
|
||||
@b
|
||||
def foo():
|
||||
pass
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
a = "string"
|
||||
|
||||
b = <warning descr="'LiteralString' object is not callable">a<caret>()</warning>
|
||||
b = <warning descr="'str' object is not callable">a<caret>()</warning>
|
||||
@@ -1 +1 @@
|
||||
<html><body><div class="definition"><pre>Class attribute <b>the_attr</b> of <a href="psi_element://#typename#ClassAttr.C">ClassAttr.C</a><br/><span style="color:#000000;">the_attr</span><span style="">: </span><span style="color:#000000;">LiteralString</span><span style=""> = </span><span style="color:#008000;font-weight:bold;">""</span></pre></div><div class="content">The documentation for the attribute.</div></body></html>
|
||||
<html><body><div class="definition"><pre>Class attribute <b>the_attr</b> of <a href="psi_element://#typename#ClassAttr.C">ClassAttr.C</a><br/><span style="color:#000000;">the_attr</span><span style="">: </span><span style="color:#000000;"><span style="color:#000080;"><a href="psi_element://#typename#str">str</a></span></span><span style=""> = </span><span style="color:#008000;font-weight:bold;">""</span></pre></div><div class="content">The documentation for the attribute.</div></body></html>
|
||||
@@ -1,3 +1,3 @@
|
||||
<html><body><div class="bottom"><icon src="AllIcons.Nodes.Class"/> <code><a href="psi_element://#typename#DefaultValues.C">DefaultValues.C</a></code></div><div class="definition"><pre><span style="color:#000080;font-weight:bold;">def </span><span style="color:#000000;">method</span><span style="">(</span><span style="color:#94558d;">self</span><span style="">=</span><span style="color:#0000ff;">42</span><span style="">,</span>
|
||||
<span style="color:#000000;">foo</span><span style="">: </span><span style="color:#000000;"><span style="color:#000080;"><a href="psi_element://#typename#list">list</a></span><span style="">[</span><span style="color:#000080;"><a href="psi_element://#typename#int">int</a></span><span style="">]</span></span><span style=""> = </span><span style="">[</span><span style="color:#0000ff;">1</span><span style="">,<br></span><span style="">                             </span><span style="color:#0000ff;">2</span><span style="">]</span><span style="">,</span>
|
||||
<span style="color:#000000;">bar</span><span style="">: </span><span style="color:#000000;">LiteralString</span><span style=""> = </span><span style="color:#008000;font-weight:bold;">"<br/>"</span><span style="">)</span> -> <span style="color:#000000;"><span style="color:#000080;font-weight:bold;">None</span></span></pre></div></body></html>
|
||||
<span style="color:#000000;">bar</span><span style="">: </span><span style="color:#000000;"><span style="color:#000080;"><a href="psi_element://#typename#str">str</a></span></span><span style=""> = </span><span style="color:#008000;font-weight:bold;">"<br/>"</span><span style="">)</span> -> <span style="color:#000000;"><span style="color:#000080;font-weight:bold;">None</span></span></pre></div></body></html>
|
||||
@@ -1 +1 @@
|
||||
Variable "x"<br/>Inferred type: LiteralString<span style=""> | </span><span style="color:#000080;"><a href="psi_element://#typename#int">int</a></span>
|
||||
Variable "x"<br/>Inferred type: <span style="color:#000080;"><a href="psi_element://#typename#str">str</a></span><span style=""> | </span><span style="color:#000080;"><a href="psi_element://#typename#int">int</a></span>
|
||||
@@ -1 +1 @@
|
||||
<html><body><div class="definition"><pre>Instance attribute <b>foo</b> of <a href="psi_element://#typename#InstanceAttr.C">InstanceAttr.C</a><br/><span style="color:#000000;">foo</span><span style="">: </span><span style="color:#000000;">LiteralString</span><span style=""> = </span><span style="color:#008000;font-weight:bold;">"Foo"</span></pre></div><div class="content">The docstring for the attribute foo.</div></body></html>
|
||||
<html><body><div class="definition"><pre>Instance attribute <b>foo</b> of <a href="psi_element://#typename#InstanceAttr.C">InstanceAttr.C</a><br/><span style="color:#000000;">foo</span><span style="">: </span><span style="color:#000000;"><span style="color:#000080;"><a href="psi_element://#typename#str">str</a></span></span><span style=""> = </span><span style="color:#008000;font-weight:bold;">"Foo"</span></pre></div><div class="content">The docstring for the attribute foo.</div></body></html>
|
||||
@@ -1 +1 @@
|
||||
<html><body><div class="bottom"><icon src="AllIcons.Nodes.Package"/> <code><a href="psi_element://#module#TupleTypeIsRenderedLowercased">TupleTypeIsRenderedLowercased</a></code></div><div class="definition"><pre><span style="color:#000000;">items</span><span style="">: </span><span style="color:#000000;"><span style="color:#000080;">tuple</span><span style="">[</span><span style="color:#000080;"><a href="psi_element://#typename#int">int</a></span><span style="">, </span>LiteralString<span style="">]</span></span><span style=""> = </span><span style="">(</span><span style="color:#0000ff;">42</span><span style="">, </span><span style="color:#008000;font-weight:bold;">'foo'</span><span style="">)</span></pre></div></body></html>
|
||||
<html><body><div class="bottom"><icon src="AllIcons.Nodes.Package"/> <code><a href="psi_element://#module#TupleTypeIsRenderedLowercased">TupleTypeIsRenderedLowercased</a></code></div><div class="definition"><pre><span style="color:#000000;">items</span><span style="">: </span><span style="color:#000000;"><span style="color:#000080;">tuple</span><span style="">[</span><span style="color:#000080;"><a href="psi_element://#typename#int">int</a></span><span style="">, </span><span style="color:#000080;"><a href="psi_element://#typename#str">str</a></span><span style="">]</span></span><span style=""> = </span><span style="">(</span><span style="color:#0000ff;">42</span><span style="">, </span><span style="color:#008000;font-weight:bold;">'foo'</span><span style="">)</span></pre></div></body></html>
|
||||
@@ -19,7 +19,7 @@ public class Py3TypeTest extends PyTestCase {
|
||||
|
||||
// PY-6702
|
||||
public void testYieldFromType() {
|
||||
doTest("LiteralString | int | float",
|
||||
doTest("str | int | float",
|
||||
"""
|
||||
def subgen():
|
||||
for i in [1, 2, 3]:
|
||||
@@ -49,7 +49,7 @@ public class Py3TypeTest extends PyTestCase {
|
||||
expr = yield from y
|
||||
return expr
|
||||
""");
|
||||
doTest("LiteralString",
|
||||
doTest("str",
|
||||
"""
|
||||
def a():
|
||||
yield 1
|
||||
@@ -611,7 +611,7 @@ public class Py3TypeTest extends PyTestCase {
|
||||
|
||||
// PY-22513
|
||||
public void testGenericKwargs() {
|
||||
doTest("dict[str, int | LiteralString]",
|
||||
doTest("dict[str, int | str]",
|
||||
"""
|
||||
from typing import Any, Dict, TypeVar
|
||||
|
||||
@@ -1132,13 +1132,13 @@ public class Py3TypeTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testFStringLiteralType() {
|
||||
doTest("LiteralString",
|
||||
doTest("str",
|
||||
"expr = f'foo'");
|
||||
}
|
||||
|
||||
// PY-35885
|
||||
public void testFunctionDunderDoc() {
|
||||
doTest("LiteralString",
|
||||
doTest("str",
|
||||
"""
|
||||
def example():
|
||||
""\"Example Docstring""\"
|
||||
@@ -1575,9 +1575,9 @@ public class Py3TypeTest extends PyTestCase {
|
||||
""";
|
||||
myFixture.configureByText(PythonFileType.INSTANCE, text);
|
||||
PyExpression dict = myFixture.findElementByText("{'foo': self.foo}", PyExpression.class);
|
||||
assertExpressionType("dict[LiteralString, Any]", dict);
|
||||
assertExpressionType("dict[str, Any]", dict);
|
||||
final PyExpression expr = myFixture.findElementByText("expr", PyExpression.class);
|
||||
assertExpressionType("dict[LiteralString, Any]", expr);
|
||||
assertExpressionType("dict[str, Any]", expr);
|
||||
}
|
||||
|
||||
public void testRecursiveDictTopDown() {
|
||||
@@ -1590,9 +1590,9 @@ public class Py3TypeTest extends PyTestCase {
|
||||
""";
|
||||
myFixture.configureByText(PythonFileType.INSTANCE, text);
|
||||
final PyExpression expr = myFixture.findElementByText("expr", PyExpression.class);
|
||||
assertExpressionType("dict[LiteralString, Any]", expr);
|
||||
assertExpressionType("dict[str, Any]", expr);
|
||||
PyExpression dict = myFixture.findElementByText("{'foo': self.foo}", PyExpression.class);
|
||||
assertExpressionType("dict[LiteralString, Any]", dict);
|
||||
assertExpressionType("dict[str, Any]", dict);
|
||||
}
|
||||
|
||||
// PY-52656
|
||||
@@ -1621,7 +1621,7 @@ public class Py3TypeTest extends PyTestCase {
|
||||
|
||||
// PY-16622
|
||||
public void testVariableEnumValueType() {
|
||||
doTest("LiteralString",
|
||||
doTest("str",
|
||||
"""
|
||||
from enum import Enum
|
||||
|
||||
@@ -1729,7 +1729,7 @@ public class Py3TypeTest extends PyTestCase {
|
||||
|
||||
// PY-59795
|
||||
public void testDictTypeFromValueModificationsConsidersOnlyRelevantAssignments() {
|
||||
doTest("dict[LiteralString, int]",
|
||||
doTest("dict[str, int]",
|
||||
"""
|
||||
d = {}
|
||||
d['foo'] = 1
|
||||
@@ -1810,22 +1810,6 @@ public class Py3TypeTest extends PyTestCase {
|
||||
expr = x.join(xs)""");
|
||||
}
|
||||
|
||||
// PY-53612
|
||||
public void testLiteralStringInFString() {
|
||||
doTest("LiteralString",
|
||||
"""
|
||||
from typing_extensions import LiteralString
|
||||
name = "foo"
|
||||
age: LiteralString = "42"
|
||||
expr = f"Hello, {name.capitalize()}. You are {age}."\s""");
|
||||
doTest("str",
|
||||
"""
|
||||
from typing_extensions import LiteralString
|
||||
name = "foo"
|
||||
age: str = str(42)
|
||||
expr = f"Hello, {name.capitalize()}. You are {age}."\s""");
|
||||
}
|
||||
|
||||
// PY-53612
|
||||
public void testLiteralStringInStringFormat() {
|
||||
doTest("LiteralString",
|
||||
@@ -1844,128 +1828,6 @@ public class Py3TypeTest extends PyTestCase {
|
||||
expr = string.format(name=name.capitalize(), age=age)""");
|
||||
}
|
||||
|
||||
// PY-53612
|
||||
public void testBinaryExprTypeWithLiteralString() {
|
||||
doTest("int",
|
||||
"expr = 1 + 2");
|
||||
doTest("LiteralString",
|
||||
"expr = '1' + '2'");
|
||||
doTest("LiteralString",
|
||||
"expr = '%s' % ('a')");
|
||||
doTest("list[int]",
|
||||
"expr = [1] + [2]");
|
||||
}
|
||||
|
||||
// PY-53612
|
||||
public void testDictTypeByModificationsWithLiteralString() {
|
||||
doTest("dict[LiteralString, int | LiteralString]",
|
||||
"""
|
||||
def f():
|
||||
expr = {'a': 3}
|
||||
expr['b'] = "s"
|
||||
"""
|
||||
);
|
||||
|
||||
doTest("dict[LiteralString, int | LiteralString]",
|
||||
"""
|
||||
def f():
|
||||
expr = {'a': 3}
|
||||
expr['b'] = "s"
|
||||
"""
|
||||
);
|
||||
|
||||
doTest("dict[LiteralString, int | list[int]]",
|
||||
"""
|
||||
def f():
|
||||
expr = {}
|
||||
expr['a'] = 0
|
||||
expr['c'] = [1, 2]"""
|
||||
);
|
||||
|
||||
doTest("dict[LiteralString, int | Any]",
|
||||
"""
|
||||
def f():
|
||||
expr = {'b': D()}
|
||||
expr['a'] = 2
|
||||
"""
|
||||
);
|
||||
|
||||
doTest("dict[LiteralString, int | LiteralString]",
|
||||
"""
|
||||
def f():
|
||||
expr = {'a': 3}
|
||||
expr['b'], t = "s", 12"""
|
||||
);
|
||||
|
||||
doTest("dict[LiteralString, int | Any]",
|
||||
"""
|
||||
def f():
|
||||
expr = {'a': 3}
|
||||
expr['a'] = var
|
||||
"""
|
||||
);
|
||||
|
||||
doTest("dict[LiteralString, int]",
|
||||
"""
|
||||
def f():
|
||||
expr = {'a': 3, 'b': 4}
|
||||
"""
|
||||
);
|
||||
|
||||
doTest("dict[LiteralString, int | LiteralString]",
|
||||
"""
|
||||
def f():
|
||||
expr = {'a': 3}
|
||||
expr.update({'a': 'str'})
|
||||
"""
|
||||
);
|
||||
|
||||
doTest("dict[LiteralString, int | Any]",
|
||||
"""
|
||||
def f():
|
||||
expr = {'a': 3}
|
||||
expr.update({'b': var})
|
||||
"""
|
||||
);
|
||||
|
||||
doTest("dict[LiteralString, int]",
|
||||
"""
|
||||
def f():
|
||||
expr = {}
|
||||
expr.update(a=1, b=2)"""
|
||||
);
|
||||
|
||||
doTest("dict[int | LiteralString, int | LiteralString]",
|
||||
"""
|
||||
def f():
|
||||
expr = {1: '3'}
|
||||
expr.update(a=1, b=2)"""
|
||||
);
|
||||
|
||||
doTest("dict[LiteralString, int | LiteralString]",
|
||||
"""
|
||||
def f():
|
||||
expr = {}
|
||||
expr['a'] = 23
|
||||
expr.update(a='m', b='n')"""
|
||||
);
|
||||
|
||||
doTest("dict[LiteralString, int | LiteralString]",
|
||||
"""
|
||||
def f():
|
||||
b, expr = 23, {'a': 3}
|
||||
expr['b'] = 'l'"""
|
||||
);
|
||||
|
||||
doTest("dict[LiteralString, int]",
|
||||
"""
|
||||
def f(): expr = {'a': 1}
|
||||
def inner():
|
||||
expr['b'] = 'a'
|
||||
"""
|
||||
);
|
||||
}
|
||||
|
||||
public void testTypeGuardList() {
|
||||
doTest("list[str]",
|
||||
"""
|
||||
@@ -2142,11 +2004,6 @@ public class Py3TypeTest extends PyTestCase {
|
||||
""");
|
||||
}
|
||||
|
||||
public void testDictCallOnDictLiteralResult() {
|
||||
doTest("dict[LiteralString, int]",
|
||||
"expr = dict({'a': 1})");
|
||||
}
|
||||
|
||||
// PY-27708
|
||||
public void testDictCompExpressionWithGenerics() {
|
||||
doTest("dict[str, (Any) -> Any]",
|
||||
|
||||
@@ -190,7 +190,7 @@ public class PyDecoratedFunctionTypeProviderTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testMakeDecoratorStack() {
|
||||
doTest("int", "(tt: LiteralString) -> int",
|
||||
doTest("int", "(tt: str) -> int",
|
||||
"""
|
||||
from typing import Callable
|
||||
from functools import wraps
|
||||
|
||||
@@ -433,8 +433,8 @@ public class PyParameterInfoTest extends LightMarkedTestCase {
|
||||
|
||||
public void testMultilineStringDefault() {
|
||||
final int offset = loadTest(1).get("<arg2>").getTextOffset();
|
||||
feignCtrlP(offset).check("length: int = 12, allowed_chars: LiteralString = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'",
|
||||
new String[]{"allowed_chars: LiteralString = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'"},
|
||||
feignCtrlP(offset).check("length: int = 12, allowed_chars: str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'",
|
||||
new String[]{"allowed_chars: str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'"},
|
||||
ArrayUtilRt.EMPTY_STRING_ARRAY);
|
||||
}
|
||||
|
||||
@@ -551,7 +551,7 @@ public class PyParameterInfoTest extends LightMarkedTestCase {
|
||||
public void testEscapingInDefaultValue() {
|
||||
final int offset = loadTest(1).get("<arg1>").getTextOffset();
|
||||
|
||||
feignCtrlP(offset).check("p: LiteralString = \"\\n\", t: LiteralString = \"\\t\", r: LiteralString = \"\\r\"", new String[]{"p: LiteralString = \"\\n\", "});
|
||||
feignCtrlP(offset).check("p: str = \"\\n\", t: str = \"\\t\", r: str = \"\\r\"", new String[]{"p: str = \"\\n\", "});
|
||||
}
|
||||
|
||||
public void testJustTypingCallable() {
|
||||
@@ -733,7 +733,7 @@ public class PyParameterInfoTest extends LightMarkedTestCase {
|
||||
feignCtrlP(marks.get("<arg3>").getTextOffset()).check("x, z: int = ...", new String[]{"x, "});
|
||||
feignCtrlP(marks.get("<arg4>").getTextOffset()).check("x, y, z: list = ...", new String[]{"x, "});
|
||||
feignCtrlP(marks.get("<arg5>").getTextOffset()).check("x, y: int = ...", new String[]{"x, "});
|
||||
feignCtrlP(marks.get("<arg6>").getTextOffset()).check("x, y: LiteralString = ...", new String[]{"x, "});
|
||||
feignCtrlP(marks.get("<arg6>").getTextOffset()).check("x, y: str = ...", new String[]{"x, "});
|
||||
feignCtrlP(marks.get("<arg7>").getTextOffset()).check("x: int = ...", new String[]{"x: int = ..."});
|
||||
feignCtrlP(marks.get("<arg8>").getTextOffset()).check("x, y, z: list = ...", new String[]{"x, "});
|
||||
}
|
||||
|
||||
@@ -4284,7 +4284,7 @@ public class PyTypeTest extends PyTestCase {
|
||||
runWithLanguageLevel(
|
||||
LanguageLevel.getLatest(),
|
||||
() -> {
|
||||
doTest("int | LiteralString",
|
||||
doTest("int | str",
|
||||
"""
|
||||
from typing import TypedDict
|
||||
class A(TypedDict, total=False):
|
||||
@@ -4419,7 +4419,7 @@ public class PyTypeTest extends PyTestCase {
|
||||
public void testFunctionReturnGeneric() {
|
||||
runWithLanguageLevel(
|
||||
LanguageLevel.getLatest(),
|
||||
() -> doTest("(Any, LiteralString, T3) -> T3",
|
||||
() -> doTest("(Any, str, T3) -> T3",
|
||||
"""
|
||||
from typing import Callable, TypeVar
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testQualifiedTypeInStringLiteral() {
|
||||
doTest("LiteralString",
|
||||
doTest("str",
|
||||
"""
|
||||
import typing
|
||||
|
||||
@@ -1300,7 +1300,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testGenericUserFunctionWithManyParamsAndNestedCall() {
|
||||
doTest("tuple[bool, int, LiteralString]",
|
||||
doTest("tuple[bool, int, str]",
|
||||
"""
|
||||
from typing import TypeVar
|
||||
|
||||
@@ -2163,7 +2163,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-53105
|
||||
public void testGenericVariadicClass() {
|
||||
doTest("A[float, bool, list[LiteralString]]",
|
||||
doTest("A[float, bool, list[str]]",
|
||||
"""
|
||||
from typing import TypeVarTuple, Generic, Tuple
|
||||
|
||||
@@ -2182,7 +2182,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-53105
|
||||
public void testGenericVariadicClassField() {
|
||||
doTest("tuple[int, float, bool, list[LiteralString]]",
|
||||
doTest("tuple[int, float, bool, list[str]]",
|
||||
"""
|
||||
from typing import TypeVarTuple, Generic, Tuple
|
||||
|
||||
@@ -2226,7 +2226,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-53105
|
||||
public void testGenericVariadicClassMethodPlus() {
|
||||
doTest("A[int, LiteralString, bool, int]",
|
||||
doTest("A[int, str, bool, int]",
|
||||
"""
|
||||
from __future__ import annotations
|
||||
from typing import TypeVarTuple, Generic, Tuple, TypeVar
|
||||
@@ -2273,7 +2273,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-53105
|
||||
public void testGenericVariadicClassMethodAddAxisPrefix() {
|
||||
doTest("Array[LiteralString, int, bool]",
|
||||
doTest("Array[str, int, bool]",
|
||||
"""
|
||||
from __future__ import annotations
|
||||
from typing import Generic, TypeVarTuple, Tuple, NewType, TypeVar
|
||||
@@ -2297,7 +2297,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-53105
|
||||
public void testGenericVariadicClassMethodAddAxisSuffix() {
|
||||
doTest("Array[list[int], bool, LiteralString]",
|
||||
doTest("Array[list[int], bool, str]",
|
||||
"""
|
||||
from __future__ import annotations
|
||||
from typing import Generic, TypeVarTuple, Tuple, NewType, TypeVar
|
||||
@@ -2321,7 +2321,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-53105
|
||||
public void testGenericVariadicClassMethodAddAxisPrefixAndSuffix() {
|
||||
doTest("Array[LiteralString, dict[int, LiteralString], int, str, list[int], bool]",
|
||||
doTest("Array[str, dict[int, str], int, str, list[int], bool]",
|
||||
"""
|
||||
from __future__ import annotations
|
||||
from typing import Generic, TypeVarTuple, Tuple, NewType, TypeVar
|
||||
@@ -2396,7 +2396,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-53105
|
||||
public void testGenericVariadicStarArgs() {
|
||||
doTest("tuple[int, LiteralString]",
|
||||
doTest("tuple[int, str]",
|
||||
"""
|
||||
from typing import TypeVarTuple, Tuple
|
||||
|
||||
@@ -2412,7 +2412,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-53105
|
||||
public void testGenericVariadicStarArgsOfGenericVariadics() {
|
||||
doTest("tuple[int, LiteralString]",
|
||||
doTest("tuple[int, str]",
|
||||
"""
|
||||
from typing import Tuple, TypeVarTuple
|
||||
|
||||
@@ -2428,7 +2428,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-53105
|
||||
public void testGenericVariadicStarArgsPrefixSuffix() {
|
||||
doTest("tuple[LiteralString, list, dict, bool, int]",
|
||||
doTest("tuple[str, list, dict, bool, int]",
|
||||
"""
|
||||
from typing import TypeVarTuple, Tuple
|
||||
|
||||
@@ -2444,7 +2444,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-53105
|
||||
public void testGenericVariadicStarArgsAndTypeVars() {
|
||||
doTest("tuple[LiteralString, list[int], bool, int]",
|
||||
doTest("tuple[str, list[int], bool, int]",
|
||||
"""
|
||||
from typing import TypeVarTuple, Tuple, TypeVar
|
||||
|
||||
@@ -3206,7 +3206,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-53105
|
||||
public void testGenericVariadicMethodCallUnification() {
|
||||
doTest("tuple[int, LiteralString, float]", """
|
||||
doTest("tuple[int, str, float]", """
|
||||
from typing import Generic, TypeVarTuple, Tuple
|
||||
|
||||
Ts = TypeVarTuple("Ts")
|
||||
@@ -3302,7 +3302,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testTypeVarsNotSpecializedOnInheritanceDistinctTypeVars() {
|
||||
doTest("tuple[int, LiteralString]",
|
||||
doTest("tuple[int, str]",
|
||||
"""
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
@@ -3327,7 +3327,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testTypeVarsNotSpecializedOnInheritanceReusedTypeVars() {
|
||||
doTest("tuple[int, LiteralString]",
|
||||
doTest("tuple[int, str]",
|
||||
"""
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
@@ -3414,7 +3414,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-53105
|
||||
public void testGenericVariadicClassSpecializesInheritedParameterAndAddsNewOne() {
|
||||
doTest("StrBoxWithExtra[int, LiteralString, float]",
|
||||
doTest("StrBoxWithExtra[int, str, float]",
|
||||
"""
|
||||
from typing import Generic, TypeVarTuple, Tuple
|
||||
|
||||
@@ -3532,7 +3532,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-53105
|
||||
public void testGenericVariadicClassTypeHintedInDocstrings() {
|
||||
doTest("tuple[int, LiteralString, float]",
|
||||
doTest("tuple[int, str, float]",
|
||||
"""
|
||||
from typing import Generic, TypeVar, TypeVarTuple, Tuple
|
||||
|
||||
@@ -3579,7 +3579,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testDecoratorWithArgumentCalledAsFunction() {
|
||||
doTest("(LiteralString) -> int",
|
||||
doTest("(str) -> int",
|
||||
"""
|
||||
from typing import Callable, TypeVar
|
||||
|
||||
@@ -3600,7 +3600,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-53105
|
||||
public void testGenericVariadicDecoratorWithArgumentCalledAsFunction() {
|
||||
doTest("(LiteralString, int) -> tuple[int, str, float]",
|
||||
doTest("(str, int) -> tuple[int, str, float]",
|
||||
"""
|
||||
from typing import Callable, TypeVar, TypeVarTuple, Tuple
|
||||
|
||||
@@ -3666,7 +3666,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-53522
|
||||
public void testGenericIteratorParameterizedWithAnotherGeneric() {
|
||||
doTest("Entry[LiteralString]",
|
||||
doTest("Entry[str]",
|
||||
"""
|
||||
from typing import Iterator, Generic, TypeVar
|
||||
|
||||
@@ -3688,7 +3688,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-53105
|
||||
public void testGenericVariadicIteratorParameterizedWithAnotherGenericVariadic() {
|
||||
doTest("Entry[LiteralString, int, float]",
|
||||
doTest("Entry[str, int, float]",
|
||||
"""
|
||||
from typing import Iterator, Generic, Tuple, TypeVarTuple
|
||||
|
||||
@@ -3795,7 +3795,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-50542
|
||||
public void testReusedTypeVarsInOppositeOrderDoNotCauseRecursiveSubstitution() {
|
||||
doTest("LiteralString",
|
||||
doTest("str",
|
||||
"""
|
||||
from typing import TypeVar
|
||||
|
||||
@@ -4045,7 +4045,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-61883
|
||||
public void testGenericUserFunctionWithManyParamsAndNestedCallWithPEP695Syntax() {
|
||||
doTest("tuple[bool, int, LiteralString]",
|
||||
doTest("tuple[bool, int, str]",
|
||||
"""
|
||||
def myid[T](x: T) -> T:
|
||||
pass
|
||||
@@ -4266,7 +4266,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-61883
|
||||
public void testGenericVariadicClassWithPEP695Syntax() {
|
||||
doTest("A[float, bool, list[LiteralString]]",
|
||||
doTest("A[float, bool, list[str]]",
|
||||
"""
|
||||
from typing import Generic, Tuple
|
||||
|
||||
@@ -4281,7 +4281,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-61883
|
||||
public void testGenericVariadicClassFieldWithPEP695Syntax() {
|
||||
doTest("tuple[int, float, bool, list[LiteralString]]",
|
||||
doTest("tuple[int, float, bool, list[str]]",
|
||||
"""
|
||||
from typing import Tuple
|
||||
|
||||
@@ -4314,7 +4314,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-61883
|
||||
public void testGenericVariadicClassMethodAddAxisPrefixWithPEP695Syntax() {
|
||||
doTest("Array[LiteralString, int, bool]",
|
||||
doTest("Array[str, int, bool]",
|
||||
"""
|
||||
from __future__ import annotations
|
||||
from typing import Tuple, NewType
|
||||
@@ -4333,7 +4333,7 @@ public class PyTypingTest extends PyTestCase {
|
||||
|
||||
// PY-61883
|
||||
public void testGenericVariadicStarArgsAndTypeVarsWithPEP695Syntax() {
|
||||
doTest("tuple[LiteralString, list[int], bool, int]",
|
||||
doTest("tuple[str, list[int], bool, int]",
|
||||
"""
|
||||
from typing import TypeVarTuple, Tuple, TypeVar
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
y = attr.ib(default=0)
|
||||
z = attr.ib(default=attr.Factory(list))
|
||||
\s
|
||||
Weak1(1, <warning descr="Expected type 'int', got 'LiteralString' instead">"str"</warning>, <warning descr="Expected type 'list', got 'int' instead">2</warning>)
|
||||
Weak1(1, <warning descr="Expected type 'int', got 'str' instead">"str"</warning>, <warning descr="Expected type 'list', got 'int' instead">2</warning>)
|
||||
|
||||
|
||||
@attr.s
|
||||
@@ -318,7 +318,7 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
y = attr.ib(default=0, type=int)
|
||||
z = attr.ib(default=attr.Factory(list), type=typing.List[int])
|
||||
\s
|
||||
Strong(1, <warning descr="Expected type 'int', got 'LiteralString' instead">"str"</warning>, <warning descr="Expected type 'list[int]', got 'list[LiteralString]' instead">["str"]</warning>)"""
|
||||
Strong(1, <warning descr="Expected type 'int', got 'str' instead">"str"</warning>, <warning descr="Expected type 'list[int]', got 'list[str]' instead">["str"]</warning>)"""
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -425,9 +425,9 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
doTestByText("""
|
||||
from typing import Annotated
|
||||
A = Annotated[bool, 'Some constraint']
|
||||
a: A = <warning descr="Expected type 'bool', got 'LiteralString' instead">'str'</warning>
|
||||
a: A = <warning descr="Expected type 'bool', got 'str' instead">'str'</warning>
|
||||
b: A = True
|
||||
c: Annotated[bool, 'Some constraint'] = <warning descr="Expected type 'bool', got 'LiteralString' instead">'str'</warning>
|
||||
c: Annotated[bool, 'Some constraint'] = <warning descr="Expected type 'bool', got 'str' instead">'str'</warning>
|
||||
d: Annotated[str, 'Some constraint'] = 'str'
|
||||
""");
|
||||
}
|
||||
@@ -535,7 +535,7 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
def a(q: int) -> str: ...
|
||||
|
||||
|
||||
expr = Y(a, '1').f(<warning descr="Expected type 'int', got 'LiteralString' instead">"42"</warning>)
|
||||
expr = Y(a, '1').f(<warning descr="Expected type 'int', got 'str' instead">"42"</warning>)
|
||||
""");
|
||||
}
|
||||
|
||||
@@ -620,7 +620,7 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
def add(x: Callable[P, int]) -> Callable[Concatenate[str, P], bool]: ...
|
||||
|
||||
|
||||
add(bar)("42", <warning descr="Expected type 'int', got 'LiteralString' instead">"42"</warning>, True)""");
|
||||
add(bar)("42", <warning descr="Expected type 'int', got 'str' instead">"42"</warning>, True)""");
|
||||
}
|
||||
|
||||
// PY-49935
|
||||
@@ -800,9 +800,9 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
|
||||
res2 = twice(a_int_b_str, b="A", a=1)
|
||||
|
||||
res3 = twice(a_int_b_str, <warning descr="Expected type 'int', got 'LiteralString' instead">"A"</warning>, <warning descr="Expected type 'str', got 'int' instead">1</warning>)
|
||||
res3 = twice(a_int_b_str, <warning descr="Expected type 'int', got 'str' instead">"A"</warning>, <warning descr="Expected type 'str', got 'int' instead">1</warning>)
|
||||
|
||||
res4 = twice(a_int_b_str, <warning descr="Expected type 'str', got 'int' instead">b=1</warning>, <warning descr="Expected type 'int', got 'LiteralString' instead">a="A"</warning>)""");
|
||||
res4 = twice(a_int_b_str, <warning descr="Expected type 'str', got 'int' instead">b=1</warning>, <warning descr="Expected type 'int', got 'str' instead">a="A"</warning>)""");
|
||||
}
|
||||
|
||||
// PY-50403
|
||||
@@ -1086,13 +1086,13 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
myClass.foo(subClass)
|
||||
myClass.foo(42)
|
||||
myClass.foo(None)
|
||||
myClass.foo(<warning descr="Expected type 'MyClass | None | int' (matched generic type 'Self | None | int'), got 'LiteralString' instead">""</warning>)
|
||||
myClass.foo(<warning descr="Expected type 'MyClass | None | int' (matched generic type 'Self | None | int'), got 'str' instead">""</warning>)
|
||||
|
||||
subClass.foo(<warning descr="Expected type 'SubClass | None | int' (matched generic type 'Self | None | int'), got 'MyClass' instead">myClass</warning>)
|
||||
subClass.foo(subClass)
|
||||
subClass.foo(42)
|
||||
subClass.foo(None)
|
||||
subClass.foo(<warning descr="Expected type 'SubClass | None | int' (matched generic type 'Self | None | int'), got 'LiteralString' instead">""</warning>)""");
|
||||
subClass.foo(<warning descr="Expected type 'SubClass | None | int' (matched generic type 'Self | None | int'), got 'str' instead">""</warning>)""");
|
||||
}
|
||||
|
||||
// PY-53104
|
||||
@@ -1287,7 +1287,7 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
|
||||
foo(1, bar, args=(0, 'foo'))
|
||||
|
||||
foo(1, bar, <warning descr="Expected type 'tuple[int, str]' (matched generic type 'tuple[*Ts]'), got 'tuple[LiteralString, int]' instead">args=('foo', 0)</warning>)
|
||||
foo(1, bar, <warning descr="Expected type 'tuple[int, str]' (matched generic type 'tuple[*Ts]'), got 'tuple[str, int]' instead">args=('foo', 0)</warning>)
|
||||
""");
|
||||
}
|
||||
|
||||
@@ -1397,9 +1397,9 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
foo('', True, 42, c=True, b='')
|
||||
|
||||
foo('', b='', c=True<warning descr="Parameter 'args' unfilled, expected '*tuple[*Ts, int]'">)</warning>
|
||||
foo('', <warning descr="Expected type '*tuple[int]' (matched generic type '*tuple[*Ts, int]'), got '*tuple[LiteralString]' instead">''</warning>, b='', c=True)
|
||||
foo('', <warning descr="Expected type '*tuple[LiteralString, int]' (matched generic type '*tuple[*Ts, int]'), got '*tuple[LiteralString, list]' instead">''</warning>, <warning descr="Expected type '*tuple[LiteralString, int]' (matched generic type '*tuple[*Ts, int]'), got '*tuple[LiteralString, list]' instead">[False]</warning>, b='', c=True)
|
||||
foo('', <warning descr="Expected type '*tuple[LiteralString, LiteralString, LiteralString, int]' (matched generic type '*tuple[*Ts, int]'), got '*tuple[LiteralString, LiteralString, LiteralString, float]' instead">''</warning>, <warning descr="Expected type '*tuple[LiteralString, LiteralString, LiteralString, int]' (matched generic type '*tuple[*Ts, int]'), got '*tuple[LiteralString, LiteralString, LiteralString, float]' instead">''</warning>, <warning descr="Expected type '*tuple[LiteralString, LiteralString, LiteralString, int]' (matched generic type '*tuple[*Ts, int]'), got '*tuple[LiteralString, LiteralString, LiteralString, float]' instead">''</warning>, <warning descr="Expected type '*tuple[LiteralString, LiteralString, LiteralString, int]' (matched generic type '*tuple[*Ts, int]'), got '*tuple[LiteralString, LiteralString, LiteralString, float]' instead">1.1</warning>, b='', c=True)
|
||||
foo('', <warning descr="Expected type '*tuple[int]' (matched generic type '*tuple[*Ts, int]'), got '*tuple[str]' instead">''</warning>, b='', c=True)
|
||||
foo('', <warning descr="Expected type '*tuple[str, int]' (matched generic type '*tuple[*Ts, int]'), got '*tuple[str, list]' instead">''</warning>, <warning descr="Expected type '*tuple[str, int]' (matched generic type '*tuple[*Ts, int]'), got '*tuple[str, list]' instead">[False]</warning>, b='', c=True)
|
||||
foo('', <warning descr="Expected type '*tuple[str, str, str, int]' (matched generic type '*tuple[*Ts, int]'), got '*tuple[str, str, str, float]' instead">''</warning>, <warning descr="Expected type '*tuple[str, str, str, int]' (matched generic type '*tuple[*Ts, int]'), got '*tuple[str, str, str, float]' instead">''</warning>, <warning descr="Expected type '*tuple[str, str, str, int]' (matched generic type '*tuple[*Ts, int]'), got '*tuple[str, str, str, float]' instead">''</warning>, <warning descr="Expected type '*tuple[str, str, str, int]' (matched generic type '*tuple[*Ts, int]'), got '*tuple[str, str, str, float]' instead">1.1</warning>, b='', c=True)
|
||||
""");
|
||||
}
|
||||
|
||||
@@ -1420,13 +1420,13 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
foo((), '', 1, b='')
|
||||
foo(([], {}), '', [], {}, 1, b='')
|
||||
|
||||
foo(('', 1), b=''<warning descr="Parameter 'args' unfilled, expected '*tuple[str, LiteralString, int, int]'">)</warning>
|
||||
foo(('', 1), <warning descr="Expected type '*tuple[str, LiteralString, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, LiteralString, LiteralString, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, LiteralString, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, LiteralString, LiteralString, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, LiteralString, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, LiteralString, LiteralString, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, LiteralString, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, LiteralString, LiteralString, int]' instead">1</warning>, b='')
|
||||
foo((1,1), <warning descr="Expected type '*tuple[str, int, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, int, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, int]' instead">1</warning>, <warning descr="Expected type '*tuple[str, int, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, int]' instead">1</warning>, b='')
|
||||
foo(('',), <warning descr="Expected type '*tuple[str, LiteralString, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, LiteralString, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, int]' instead">1</warning>, <warning descr="Expected type '*tuple[str, LiteralString, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, int]' instead">1</warning>, b='')
|
||||
foo(('', 1), b=''<warning descr="Parameter 'args' unfilled, expected '*tuple[str, str, int, int]'">)</warning>
|
||||
foo(('', 1), <warning descr="Expected type '*tuple[str, str, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, str, str, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, str, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, str, str, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, str, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, str, str, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, str, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, str, str, int]' instead">1</warning>, b='')
|
||||
foo((1,1), <warning descr="Expected type '*tuple[str, int, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, int, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, int]' instead">1</warning>, <warning descr="Expected type '*tuple[str, int, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, int]' instead">1</warning>, b='')
|
||||
foo(('',), <warning descr="Expected type '*tuple[str, str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, int]' instead">1</warning>, <warning descr="Expected type '*tuple[str, str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, int]' instead">1</warning>, b='')
|
||||
x: Any
|
||||
foo((), <warning descr="Expected type '*tuple[str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, Any]' instead">''</warning>, <warning descr="Expected type '*tuple[str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, Any]' instead">42</warning>, <warning descr="Expected type '*tuple[str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, Any]' instead">x</warning>, b='')
|
||||
foo(([], {}), <warning descr="Expected type '*tuple[str, list, TypedDict, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, list, TypedDict]' instead">''</warning>, <warning descr="Expected type '*tuple[str, list, TypedDict, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, list, TypedDict]' instead">[]</warning>, <warning descr="Expected type '*tuple[str, list, TypedDict, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, list, TypedDict]' instead">{}</warning>, b='')
|
||||
foo((), <warning descr="Expected type '*tuple[str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, Any]' instead">''</warning>, <warning descr="Expected type '*tuple[str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, Any]' instead">42</warning>, <warning descr="Expected type '*tuple[str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, Any]' instead">x</warning>, b='')
|
||||
foo(([], {}), <warning descr="Expected type '*tuple[str, list, TypedDict, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, list, TypedDict]' instead">''</warning>, <warning descr="Expected type '*tuple[str, list, TypedDict, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, list, TypedDict]' instead">[]</warning>, <warning descr="Expected type '*tuple[str, list, TypedDict, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, list, TypedDict]' instead">{}</warning>, b='')
|
||||
""");
|
||||
}
|
||||
|
||||
@@ -1465,13 +1465,13 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
foo((), '', 1, b='')
|
||||
foo(([], {}), '', [], {}, 1, b='')
|
||||
|
||||
foo(('', 1), b=''<warning descr="Parameter 'args' unfilled, expected '*tuple[str, LiteralString, int, int]'">)</warning>
|
||||
foo(('', 1), <warning descr="Expected type '*tuple[str, LiteralString, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, LiteralString, LiteralString, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, LiteralString, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, LiteralString, LiteralString, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, LiteralString, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, LiteralString, LiteralString, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, LiteralString, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, LiteralString, LiteralString, int]' instead">1</warning>, b='')
|
||||
foo((1,1), <warning descr="Expected type '*tuple[str, int, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, int, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, int]' instead">1</warning>, <warning descr="Expected type '*tuple[str, int, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, int]' instead">1</warning>, b='')
|
||||
foo(('',), <warning descr="Expected type '*tuple[str, LiteralString, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, LiteralString, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, int]' instead">1</warning>, <warning descr="Expected type '*tuple[str, LiteralString, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, int]' instead">1</warning>, b='')
|
||||
foo(('', 1), b=''<warning descr="Parameter 'args' unfilled, expected '*tuple[str, str, int, int]'">)</warning>
|
||||
foo(('', 1), <warning descr="Expected type '*tuple[str, str, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, str, str, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, str, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, str, str, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, str, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, str, str, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, str, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, str, str, int]' instead">1</warning>, b='')
|
||||
foo((1,1), <warning descr="Expected type '*tuple[str, int, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, int, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, int]' instead">1</warning>, <warning descr="Expected type '*tuple[str, int, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, int]' instead">1</warning>, b='')
|
||||
foo(('',), <warning descr="Expected type '*tuple[str, str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, int]' instead">1</warning>, <warning descr="Expected type '*tuple[str, str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, int]' instead">1</warning>, b='')
|
||||
x: Any
|
||||
foo((), <warning descr="Expected type '*tuple[str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, Any]' instead">''</warning>, <warning descr="Expected type '*tuple[str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, Any]' instead">42</warning>, <warning descr="Expected type '*tuple[str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, Any]' instead">x</warning>, b='')
|
||||
foo(([], {}), <warning descr="Expected type '*tuple[str, list, TypedDict, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, list, TypedDict]' instead">''</warning>, <warning descr="Expected type '*tuple[str, list, TypedDict, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, list, TypedDict]' instead">[]</warning>, <warning descr="Expected type '*tuple[str, list, TypedDict, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, list, TypedDict]' instead">{}</warning>, b='')
|
||||
foo((), <warning descr="Expected type '*tuple[str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, Any]' instead">''</warning>, <warning descr="Expected type '*tuple[str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, Any]' instead">42</warning>, <warning descr="Expected type '*tuple[str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, Any]' instead">x</warning>, b='')
|
||||
foo(([], {}), <warning descr="Expected type '*tuple[str, list, TypedDict, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, list, TypedDict]' instead">''</warning>, <warning descr="Expected type '*tuple[str, list, TypedDict, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, list, TypedDict]' instead">[]</warning>, <warning descr="Expected type '*tuple[str, list, TypedDict, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, list, TypedDict]' instead">{}</warning>, b='')
|
||||
""");
|
||||
}
|
||||
|
||||
@@ -1492,13 +1492,13 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
foo((), '', 1, b='')
|
||||
foo(([], {}), '', [], {}, 1, b='')
|
||||
|
||||
foo(('', 1), b=''<warning descr="Parameter 'args' unfilled, expected '*tuple[str, LiteralString, int, int]'">)</warning>
|
||||
foo(('', 1), <warning descr="Expected type '*tuple[str, LiteralString, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, LiteralString, LiteralString, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, LiteralString, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, LiteralString, LiteralString, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, LiteralString, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, LiteralString, LiteralString, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, LiteralString, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, LiteralString, LiteralString, int]' instead">1</warning>, b='')
|
||||
foo((1,1), <warning descr="Expected type '*tuple[str, int, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, int, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, int]' instead">1</warning>, <warning descr="Expected type '*tuple[str, int, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, int]' instead">1</warning>, b='')
|
||||
foo(('',), <warning descr="Expected type '*tuple[str, LiteralString, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, LiteralString, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, int]' instead">1</warning>, <warning descr="Expected type '*tuple[str, LiteralString, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, int]' instead">1</warning>, b='')
|
||||
foo(('', 1), b=''<warning descr="Parameter 'args' unfilled, expected '*tuple[str, str, int, int]'">)</warning>
|
||||
foo(('', 1), <warning descr="Expected type '*tuple[str, str, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, str, str, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, str, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, str, str, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, str, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, str, str, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, str, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, str, str, int]' instead">1</warning>, b='')
|
||||
foo((1,1), <warning descr="Expected type '*tuple[str, int, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, int, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, int]' instead">1</warning>, <warning descr="Expected type '*tuple[str, int, int, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, int]' instead">1</warning>, b='')
|
||||
foo(('',), <warning descr="Expected type '*tuple[str, str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, int]' instead">''</warning>, <warning descr="Expected type '*tuple[str, str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, int]' instead">1</warning>, <warning descr="Expected type '*tuple[str, str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, int]' instead">1</warning>, b='')
|
||||
x: Any
|
||||
foo((), <warning descr="Expected type '*tuple[str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, Any]' instead">''</warning>, <warning descr="Expected type '*tuple[str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, Any]' instead">42</warning>, <warning descr="Expected type '*tuple[str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, int, Any]' instead">x</warning>, b='')
|
||||
foo(([], {}), <warning descr="Expected type '*tuple[str, list, TypedDict, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, list, TypedDict]' instead">''</warning>, <warning descr="Expected type '*tuple[str, list, TypedDict, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, list, TypedDict]' instead">[]</warning>, <warning descr="Expected type '*tuple[str, list, TypedDict, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[LiteralString, list, TypedDict]' instead">{}</warning>, b='')
|
||||
foo((), <warning descr="Expected type '*tuple[str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, Any]' instead">''</warning>, <warning descr="Expected type '*tuple[str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, Any]' instead">42</warning>, <warning descr="Expected type '*tuple[str, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, int, Any]' instead">x</warning>, b='')
|
||||
foo(([], {}), <warning descr="Expected type '*tuple[str, list, TypedDict, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, list, TypedDict]' instead">''</warning>, <warning descr="Expected type '*tuple[str, list, TypedDict, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, list, TypedDict]' instead">[]</warning>, <warning descr="Expected type '*tuple[str, list, TypedDict, int]' (matched generic type '*tuple[str, *Ts, int]'), got '*tuple[str, list, TypedDict]' instead">{}</warning>, b='')
|
||||
""");
|
||||
}
|
||||
|
||||
@@ -1515,8 +1515,8 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
foo(1)
|
||||
foo(1, 2, 3)
|
||||
|
||||
foo(<warning descr="Expected type 'int', got 'LiteralString' instead">''</warning>)
|
||||
foo(1, <warning descr="Expected type 'int', got 'LiteralString' instead">''</warning>)
|
||||
foo(<warning descr="Expected type 'int', got 'str' instead">''</warning>)
|
||||
foo(1, <warning descr="Expected type 'int', got 'str' instead">''</warning>)
|
||||
""");
|
||||
}
|
||||
|
||||
@@ -1633,7 +1633,7 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
|
||||
IntTuple = tuple[int, *Ts]
|
||||
|
||||
c: IntTuple[()] = <warning descr="Expected type 'tuple[int]', got 'tuple[int, LiteralString]' instead">(1, "")</warning>
|
||||
c: IntTuple[()] = <warning descr="Expected type 'tuple[int]', got 'tuple[int, str]' instead">(1, "")</warning>
|
||||
""");
|
||||
}
|
||||
|
||||
@@ -1806,8 +1806,7 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
public void testLiteralStringEqualsToStr() {
|
||||
doTestByText("""
|
||||
from typing_extensions import LiteralString
|
||||
literal_string: LiteralString
|
||||
s: str = literal_string
|
||||
s: str
|
||||
literal_string: LiteralString = <warning descr="Expected type 'LiteralString', got 'str' instead">s</warning>
|
||||
literal_string: LiteralString = "hello"
|
||||
""");
|
||||
@@ -1828,6 +1827,7 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
|
||||
plain_string: str
|
||||
expect_literal_string(<warning descr="Expected type 'LiteralString', got 'str' instead">literal_string + plain_string</warning>)
|
||||
expect_literal_string(<warning descr="Expected type 'LiteralString', got 'str' instead">plain_string + literal_string</warning>)
|
||||
""");
|
||||
}
|
||||
|
||||
@@ -1872,7 +1872,7 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
def literal_identity(s: LiteralString) -> LiteralString:
|
||||
return s
|
||||
hello: Literal["hello"] = "hello"
|
||||
y1 = literal_identity(hello) # no warning expected
|
||||
literal_identity(hello)
|
||||
""");
|
||||
}
|
||||
|
||||
@@ -1898,7 +1898,7 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
plain_string: str
|
||||
literal_string: LiteralString
|
||||
calc('literal string', plain_string)
|
||||
#calc(literal_string, plain_string) # treat LiteralStrings as str in generic substitution todo lada uncomment
|
||||
calc(literal_string, <warning descr="Expected type 'LiteralString' (matched generic type 'T'), got 'str' instead">plain_string</warning>)
|
||||
""");
|
||||
}
|
||||
|
||||
|
||||
@@ -779,7 +779,7 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
F = TypeVar('F', bound=int)
|
||||
|
||||
def deco(func: F) -> F:
|
||||
return <warning descr="Expected type 'F', got 'LiteralString' instead">""</warning>""")
|
||||
return <warning descr="Expected type 'F', got 'str' instead">""</warning>""")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -961,7 +961,7 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
a: Literal["22"] = f"22"
|
||||
b: Literal["22"] = <warning descr="Expected type 'Literal[\\"22\\"]', got 'Literal[f\\"32\\"]' instead">f"32"</warning>
|
||||
two = "2"
|
||||
c: Literal["22"] = <warning descr="Expected type 'Literal[\\"22\\"]', got 'LiteralString' instead">f"2{two}"</warning>""")
|
||||
c: Literal["22"] = <warning descr="Expected type 'Literal[\\"22\\"]', got 'str' instead">f"2{two}"</warning>""")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -990,7 +990,7 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
pass
|
||||
|
||||
def foo(cb: Callback[int]):
|
||||
cb(<warning descr="Expected type 'int' (matched generic type '_T'), got 'LiteralString' instead">"42"</warning>)""")
|
||||
cb(<warning descr="Expected type 'int' (matched generic type '_T'), got 'str' instead">"42"</warning>)""")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1057,17 +1057,17 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
class Point(TypedDict):
|
||||
x: int
|
||||
y: int
|
||||
p1: Point = {'x': 0, 'y': <warning descr="Expected type 'int', got 'LiteralString' instead">'a'</warning>}
|
||||
p2: NotPoint = {'x': <warning descr="Expected type 'int', got 'LiteralString' instead">'x'</warning>, 'y': <warning descr="Expected type 'str', got 'int' instead">42</warning>}
|
||||
p1: Point = {'x': 0, 'y': <warning descr="Expected type 'int', got 'str' instead">'a'</warning>}
|
||||
p2: NotPoint = {'x': <warning descr="Expected type 'int', got 'str' instead">'x'</warning>, 'y': <warning descr="Expected type 'str', got 'int' instead">42</warning>}
|
||||
p3: Point = <warning descr="Expected type 'Point', got 'NotPoint' instead">p2</warning>
|
||||
p4: Point = <warning descr="TypedDict 'Point' has missing keys: 'x', 'y'">{}</warning>
|
||||
p5: Point = {'x': 0, 'y': 0, <warning descr="Extra key 'z' for TypedDict 'Point'">'z': 123</warning>, <warning descr="Extra key 'k' for TypedDict 'Point'">'k': 6</warning>}
|
||||
p6: Point = <warning descr="TypedDict 'Point' has missing key: 'x'">{'y': 123}</warning>
|
||||
p7: Movie = dict(name='Alien', year=1979)
|
||||
p8: Movie = dict(name='Alien', year=<warning descr="Expected type 'int', got 'LiteralString' instead">'1979'</warning>)
|
||||
p8: Movie = dict(name='Alien', year=<warning descr="Expected type 'int', got 'str' instead">'1979'</warning>)
|
||||
p9: Movie = dict(name='Alien', year=1979, <warning descr="Extra key 'director' for TypedDict 'Movie'">director='Ridley Scott'</warning>)
|
||||
p10 = {'x': 'x', 'y': 42, 'z': 42}
|
||||
p11: Point = <warning descr="Expected type 'Point', got 'dict[LiteralString, LiteralString | int]' instead">p10</warning>"""
|
||||
p11: Point = <warning descr="Expected type 'Point', got 'dict[str, str | int]' instead">p10</warning>"""
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1079,9 +1079,9 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
from typing import TypedDict
|
||||
Movie = TypedDict('Movie', {'name': str, 'year': int})
|
||||
m1: Movie = dict(name='Alien', year=1979)
|
||||
m2: Movie = dict(name='Alien', year=<warning descr="Expected type 'int', got 'LiteralString' instead">'1979'</warning>)
|
||||
m2: Movie = dict(name='Alien', year=<warning descr="Expected type 'int', got 'str' instead">'1979'</warning>)
|
||||
m3: Movie = typing.cast(Movie, dict(zip(['name', 'year'], ['Alien', 1979])))
|
||||
m4: Movie = {'name': 'Alien', 'year': <warning descr="Expected type 'int', got 'LiteralString' instead">'1979'</warning>}
|
||||
m4: Movie = {'name': 'Alien', 'year': <warning descr="Expected type 'int', got 'str' instead">'1979'</warning>}
|
||||
m5 = Movie(name='Garden State', year=2004)"""));
|
||||
}
|
||||
|
||||
@@ -1147,8 +1147,8 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
movie2 = Movie2()
|
||||
s: str = movie['address'][0]
|
||||
s: str = movie2['address'][0]
|
||||
s: str = movie['address'][<warning descr="Unexpected type(s):(LiteralString)Possible type(s):(int)(slice)">'i'</warning>]
|
||||
s2: str = movie2['address'][<warning descr="Unexpected type(s):(LiteralString)Possible type(s):(int)(slice)">'i'</warning>]
|
||||
s: str = movie['address'][<warning descr="Unexpected type(s):(str)Possible type(s):(int)(slice)">'i'</warning>]
|
||||
s2: str = movie2['address'][<warning descr="Unexpected type(s):(str)Possible type(s):(int)(slice)">'i'</warning>]
|
||||
"""));
|
||||
}
|
||||
|
||||
@@ -1414,13 +1414,13 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
z = {'foo': 'bar'}
|
||||
n = {"foo": "", "quux": 3}
|
||||
f(<warning descr="Expected type 'C', got 'dict' instead">y</warning>)
|
||||
f(<warning descr="Expected type 'C', got 'dict[LiteralString, int | LiteralString]' instead">n</warning>)
|
||||
f(<warning descr="Expected type 'C', got 'dict[str, int | str]' instead">n</warning>)
|
||||
f(z)
|
||||
f(x=<warning descr="Expected type 'C', got 'dict' instead">y</warning>)
|
||||
f(x=<warning descr="Expected type 'C', got 'dict[LiteralString, int | LiteralString]' instead">n</warning>)
|
||||
f(x=<warning descr="Expected type 'C', got 'dict[str, int | str]' instead">n</warning>)
|
||||
f(x=z)
|
||||
z2: C = <warning descr="Expected type 'C', got 'dict' instead">y</warning>
|
||||
z2: C = <warning descr="Expected type 'C', got 'dict[LiteralString, int | LiteralString]' instead">n</warning>
|
||||
z2: C = <warning descr="Expected type 'C', got 'dict[str, int | str]' instead">n</warning>
|
||||
z2: C = z""")
|
||||
);
|
||||
}
|
||||
@@ -1433,7 +1433,7 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
class Foo(TypedDict):
|
||||
foo: Literal['bar']
|
||||
a: Foo = {'foo': 'bar'}
|
||||
b: Foo = {'foo': <warning descr="Expected type 'Literal['bar']', got 'LiteralString' instead">'baz'</warning>}""")
|
||||
b: Foo = {'foo': <warning descr="Expected type 'Literal['bar']', got 'str' instead">'baz'</warning>}""")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1473,8 +1473,8 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
0: 'zero',
|
||||
}
|
||||
}
|
||||
s: HardDict = {'a': 'xx', 'd': <warning descr="Expected type 'NotSoHardDict', got 'dict[LiteralString, dict[int, LiteralString] | LiteralString]' instead">t</warning>}
|
||||
s1: HardDict = <warning descr="Expected type 'HardDict', got 'dict[LiteralString, dict[int, LiteralString] | LiteralString]' instead">t</warning>
|
||||
s: HardDict = {'a': 'xx', 'd': <warning descr="Expected type 'NotSoHardDict', got 'dict[str, dict[int, str] | str]' instead">t</warning>}
|
||||
s1: HardDict = <warning descr="Expected type 'HardDict', got 'dict[str, dict[int, str] | str]' instead">t</warning>
|
||||
t1 = {
|
||||
'a': 'xx',
|
||||
'd': {
|
||||
@@ -1482,8 +1482,8 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
'd': {}
|
||||
}
|
||||
}
|
||||
s2: HardDict = {'a': 'xx', 'd': <warning descr="Expected type 'NotSoHardDict', got 'dict[LiteralString, dict[LiteralString, dict | int] | LiteralString]' instead">t1</warning>}
|
||||
s3: HardDict = <warning descr="Expected type 'HardDict', got 'dict[LiteralString, dict[LiteralString, dict | int] | LiteralString]' instead">t1</warning>
|
||||
s2: HardDict = {'a': 'xx', 'd': <warning descr="Expected type 'NotSoHardDict', got 'dict[str, dict[str, dict | int] | str]' instead">t1</warning>}
|
||||
s3: HardDict = <warning descr="Expected type 'HardDict', got 'dict[str, dict[str, dict | int] | str]' instead">t1</warning>
|
||||
s4: HardDict = <warning descr="TypedDict 'HardDict' has missing key: 'a'">{
|
||||
'd': {
|
||||
'a': 'a',
|
||||
@@ -1513,7 +1513,7 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
group: list[T]
|
||||
class GroupWithOtherKey(Group, Generic[T1]):
|
||||
some_other_key: T1
|
||||
group: GroupWithOtherKey[str, int] = {"key": <warning descr="Expected type 'str', got 'int' instead">1</warning>, "group": [], "some_other_key": <warning descr="Expected type 'int', got 'LiteralString' instead">''</warning>}""")
|
||||
group: GroupWithOtherKey[str, int] = {"key": <warning descr="Expected type 'str', got 'int' instead">1</warning>, "group": [], "some_other_key": <warning descr="Expected type 'int', got 'str' instead">''</warning>}""")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -162,8 +162,8 @@ public class PyTypedDictInspectionTest extends PyInspectionTestCase {
|
||||
m = Horror(name='Alien', year=1979)
|
||||
d={'name':'Garden State', 'year':2004}
|
||||
m.update(d)
|
||||
m.update({'name':'Garden State', 'year':<warning descr="Expected type 'int | None', got 'LiteralString' instead">'2004'</warning>, <warning descr="TypedDict \\"Horror\\" cannot have key 'based_on'">'based_on'</warning>: 'book'})
|
||||
m.update(name=<warning descr="Expected type 'str', got 'int' instead">1984</warning>, year=1984, based_on_book=<warning descr="Expected type 'bool', got 'LiteralString' instead">'yes'</warning>)
|
||||
m.update({'name':'Garden State', 'year':<warning descr="Expected type 'int | None', got 'str' instead">'2004'</warning>, <warning descr="TypedDict \\"Horror\\" cannot have key 'based_on'">'based_on'</warning>: 'book'})
|
||||
m.update(name=<warning descr="Expected type 'str', got 'int' instead">1984</warning>, year=1984, based_on_book=<warning descr="Expected type 'bool', got 'str' instead">'yes'</warning>)
|
||||
m.update([('name',<warning descr="Expected type 'str', got 'int' instead">1984</warning>), ('year',None)])""");
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public class PyTypedDictInspectionTest extends PyInspectionTestCase {
|
||||
year: int
|
||||
movie = Movie()
|
||||
movie2 = Movie2()
|
||||
movie['year'], movie2['year'] = <warning descr="Expected type 'int', got 'LiteralString' instead">'1984'</warning>, <warning descr="Expected type 'int', got 'LiteralString' instead">'1984'</warning>
|
||||
movie['year'], movie2['year'] = <warning descr="Expected type 'int', got 'str' instead">'1984'</warning>, <warning descr="Expected type 'int', got 'str' instead">'1984'</warning>
|
||||
""");
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ class TypeIgnoreInspectionSuppressorTest : PyTestCase() {
|
||||
fun testIgnoreType() {
|
||||
doTestByText("""
|
||||
print(2 + 'foo') # type: ignore
|
||||
print(2 + <warning descr="Expected type 'int', got 'LiteralString' instead">'foo'</warning>)
|
||||
print(2 + <warning descr="Expected type 'int', got 'str' instead">'foo'</warning>)
|
||||
""")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user