From ad5b55918e1476279a807fd487045cd63f9df081 Mon Sep 17 00:00:00 2001 From: "lada.gagina" Date: Tue, 4 Jul 2023 15:41:27 +0200 Subject: [PATCH] Revert tests with over-inferring LiteralString (cherry picked from commit 0c92e1c64362e2834b01b4e0bcbcedfefe4febe0) IJ-MR-112631 GitOrigin-RevId: 233abfde16b19e96c5bc39c77eef1a240aa1b3e8 --- .../python/markdown/PyCodeFenceTest.kt | 2 +- .../PyTypeCheckerInspection/Assignment.py | 2 +- .../PyTypeCheckerInspection/BuiltinsPy3.py | 8 +- .../PyTypeCheckerInspection/CallOperator.py | 4 +- .../ChainedComparisonsGenericMatching.py | 2 +- .../ClassLevelAssignment.py | 8 +- .../DataclassesReplace/a.py | 6 +- .../DelegatedGenerator.py | 2 +- .../FunctionReturnTypePy3.py | 4 +- .../HomogeneousTuples.py | 2 +- .../InitializingDataclass/a.py | 20 +-- .../InitializingNewType.py | 4 +- .../InitializingTypingNamedTuple.py | 32 ++-- .../MapArgumentsInOppositeOrderPy3.py | 2 +- .../NewTypeAsParameter.py | 2 +- .../OptionalOfBoundTypeVarInWarnings.py | 2 +- ...tionsAndTheirTypingAliasesAreEquivalent.py | 20 +-- .../PyTypeCheckerInspection/ReAssignment.py | 4 +- .../StructUnpackPy3/a.py | 2 +- .../TypeDeclarationAndAssignment.py | 2 +- .../TypedDictInReturnType.py | 6 +- .../TypedDictInStub/a.py | 2 +- .../TypingAnnotatedTypeMultiFile/a.py | 2 +- .../TypingCallableCall.py | 2 +- .../a.py | 2 +- .../TypingTypeVarWithUnresolvedBound.py | 2 +- .../WithOpenBinaryPy3.py | 2 +- .../descriptorAttribute.py | 4 +- .../AnnotationImportTypingAny/main_after.py | 4 +- .../AnnotationImportTypingUnion/main_after.py | 4 +- ...ationLocalChainedAssignmentTarget_after.py | 5 +- .../annotationLocalForTarget_after.py | 3 - ...tationLocalSimpleAssignmentTarget_after.py | 5 +- ...tionLocalUnpackedAssignmentTarget_after.py | 5 +- .../annotationTupleType_after.py | 4 +- .../overloadedGenerics/OverloadedGenerics.py | 6 +- ...verloadsWithDifferentNumberOfParameters.py | 16 +- .../PyRemoveCallQuickFixTest/class.py | 2 +- .../PyRemoveCallQuickFixTest/decorator.py | 2 +- .../PyRemoveCallQuickFixTest/expression.py | 2 +- python/testData/quickdoc/ClassAttr.html | 2 +- python/testData/quickdoc/DefaultValues.html | 2 +- .../quickdoc/HoverOverControlFlowUnion.html | 2 +- python/testData/quickdoc/InstanceAttr.html | 2 +- .../TupleTypeIsRenderedLowercased.html | 2 +- .../com/jetbrains/python/Py3TypeTest.java | 165 ++---------------- .../PyDecoratedFunctionTypeProviderTest.java | 2 +- .../jetbrains/python/PyParameterInfoTest.java | 8 +- .../com/jetbrains/python/PyTypeTest.java | 4 +- .../com/jetbrains/python/PyTypingTest.java | 54 +++--- .../Py3TypeCheckerInspectionTest.java | 78 ++++----- .../PyTypeCheckerInspectionTest.java | 40 ++--- .../PyTypedDictInspectionTest.java | 6 +- .../TypeIgnoreInspectionSuppressorTest.kt | 2 +- 54 files changed, 212 insertions(+), 367 deletions(-) diff --git a/python/python-markdown/test/com/jetbrains/python/markdown/PyCodeFenceTest.kt b/python/python-markdown/test/com/jetbrains/python/markdown/PyCodeFenceTest.kt index aea9f3d7380b..7c78ba865b6f 100644 --- a/python/python-markdown/test/com/jetbrains/python/markdown/PyCodeFenceTest.kt +++ b/python/python-markdown/test/com/jetbrains/python/markdown/PyCodeFenceTest.kt @@ -142,7 +142,7 @@ class PyCodeFenceTest : PyTestCase() { expect_str("abc") # Should warn - expect_bytes("abc") + expect_bytes("abc") ``` """.trimIndent()) myFixture.enableInspections(PyTypeCheckerInspection::class.java) diff --git a/python/testData/inspections/PyTypeCheckerInspection/Assignment.py b/python/testData/inspections/PyTypeCheckerInspection/Assignment.py index 848a5b2a3f66..3791eb7f27d6 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/Assignment.py +++ b/python/testData/inspections/PyTypeCheckerInspection/Assignment.py @@ -1,5 +1,5 @@ def f(): - x1: int = 'foo' + x1: int = 'foo' x2: str = 'bar' x3: int = 0 x4: str = 1 diff --git a/python/testData/inspections/PyTypeCheckerInspection/BuiltinsPy3.py b/python/testData/inspections/PyTypeCheckerInspection/BuiltinsPy3.py index fa68c597b58e..5a34ce9f33a2 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/BuiltinsPy3.py +++ b/python/testData/inspections/PyTypeCheckerInspection/BuiltinsPy3.py @@ -1,6 +1,6 @@ def test_operators(): - print(2 + 'foo') - print(b'foo' + 'bar') + print(2 + 'foo') + print(b'foo' + 'bar') print(b'foo' + 3) @@ -11,6 +11,6 @@ def test_numerics(): float(False) complex(False) divmod(False, False) - divmod(b'foo', 'bar') + divmod(b'foo', 'bar') pow(False, True) - round(False, 'foo') + round(False, 'foo') diff --git a/python/testData/inspections/PyTypeCheckerInspection/CallOperator.py b/python/testData/inspections/PyTypeCheckerInspection/CallOperator.py index ec9be4d057aa..432b51eddb77 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/CallOperator.py +++ b/python/testData/inspections/PyTypeCheckerInspection/CallOperator.py @@ -3,5 +3,5 @@ class Foo: return arg bar = Foo() -bar.__call__("s") -bar("s") \ No newline at end of file +bar.__call__("s") +bar("s") \ No newline at end of file diff --git a/python/testData/inspections/PyTypeCheckerInspection/ChainedComparisonsGenericMatching.py b/python/testData/inspections/PyTypeCheckerInspection/ChainedComparisonsGenericMatching.py index b6a5f8bef6f8..0e552c0db09d 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/ChainedComparisonsGenericMatching.py +++ b/python/testData/inspections/PyTypeCheckerInspection/ChainedComparisonsGenericMatching.py @@ -11,4 +11,4 @@ class MyClass(Generic[T]): pass -x = MyClass(1) < MyClass(2) < MyClass('foo') +x = MyClass(1) < MyClass(2) < MyClass('foo') diff --git a/python/testData/inspections/PyTypeCheckerInspection/ClassLevelAssignment.py b/python/testData/inspections/PyTypeCheckerInspection/ClassLevelAssignment.py index 2bc3ea3fb731..254a4d056b80 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/ClassLevelAssignment.py +++ b/python/testData/inspections/PyTypeCheckerInspection/ClassLevelAssignment.py @@ -9,13 +9,13 @@ class C: def f(self): self.x = 1 - self.x = 'bar' + self.x = 'bar' self.y = 1 - self.y = 'bar' + self.y = 'bar' self.z = 1 - self.z = 'bar' + self.z = 'bar' self.class_var = 1 - self.class_var = 'bar' + self.class_var = 'bar' C.class_var = 1 C.class_var = 'bar' diff --git a/python/testData/inspections/PyTypeCheckerInspection/DataclassesReplace/a.py b/python/testData/inspections/PyTypeCheckerInspection/DataclassesReplace/a.py index 76c8f38b1ce5..4ec7c85b1941 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/DataclassesReplace/a.py +++ b/python/testData/inspections/PyTypeCheckerInspection/DataclassesReplace/a.py @@ -9,7 +9,7 @@ class A: replace(A(1)) replace(A(1), a=1, b="abc") -replace(A(1), a="str", b=1) +replace(A(1), a="str", b=1) @dataclass @@ -20,7 +20,7 @@ class B: replace(B(1)) replace(B(1), a=1) -replace(B(1), a="str") +replace(B(1), a="str") @dataclass @@ -31,7 +31,7 @@ class C: replace(C(1)) replace(C(1), a=1, b="str") -replace(C(1), a="str", b=1) +replace(C(1), a="str", b=1) class D: diff --git a/python/testData/inspections/PyTypeCheckerInspection/DelegatedGenerator.py b/python/testData/inspections/PyTypeCheckerInspection/DelegatedGenerator.py index 78eda3358309..646fdf8a9977 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/DelegatedGenerator.py +++ b/python/testData/inspections/PyTypeCheckerInspection/DelegatedGenerator.py @@ -8,4 +8,4 @@ def f(x: int) -> int: def test(): - return f((yield from a())) \ No newline at end of file + return f((yield from a())) \ No newline at end of file diff --git a/python/testData/inspections/PyTypeCheckerInspection/FunctionReturnTypePy3.py b/python/testData/inspections/PyTypeCheckerInspection/FunctionReturnTypePy3.py index a9b9554a16a1..50ef2a06ff87 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/FunctionReturnTypePy3.py +++ b/python/testData/inspections/PyTypeCheckerInspection/FunctionReturnTypePy3.py @@ -7,7 +7,7 @@ def b(x: int) -> List[str]: return [1,2] def c() -> int: - return 'abc' + return 'abc' def d(x: int) -> List[str]: return [str(x)] @@ -26,7 +26,7 @@ def f() -> Optional[str]: def g(x) -> int: if x: - return 'abc' + return 'abc' else: return {} diff --git a/python/testData/inspections/PyTypeCheckerInspection/HomogeneousTuples.py b/python/testData/inspections/PyTypeCheckerInspection/HomogeneousTuples.py index 2d670c53dfac..75bf017666b8 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/HomogeneousTuples.py +++ b/python/testData/inspections/PyTypeCheckerInspection/HomogeneousTuples.py @@ -9,7 +9,7 @@ int_and_bool = (42, True) expects_many_ints(int_and_bool) int_and_str = (42, 'foo') -expects_many_ints(int_and_str) +expects_many_ints(int_and_str) booleans = (True, False) # type: Tuple[bool, ...] expects_many_ints(booleans) diff --git a/python/testData/inspections/PyTypeCheckerInspection/InitializingDataclass/a.py b/python/testData/inspections/PyTypeCheckerInspection/InitializingDataclass/a.py index 18d223ad56e5..6891cccbd950 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/InitializingDataclass/a.py +++ b/python/testData/inspections/PyTypeCheckerInspection/InitializingDataclass/a.py @@ -8,10 +8,10 @@ class A: z: float = 0.0 A(1, "a") -A("a", 1) +A("a", 1) A(1, "a", 1.0) -A("a", 1, "b") +A("a", 1, "b") @dataclasses.dataclass(init=True) @@ -21,10 +21,10 @@ class A2: z: float = 0.0 A2(1, "a") -A2("a", 1) +A2("a", 1) A2(1, "a", 1.0) -A2("a", 1, "b") +A2("a", 1, "b") @dataclasses.dataclass(init=False) @@ -55,7 +55,7 @@ class B2: self.z = 0.0 B2(1) -B2("1") +B2("1") @dataclasses.dataclass @@ -64,7 +64,7 @@ class C1: b: int C1(1) -C1("1") +C1("1") @dataclasses.dataclass @@ -73,7 +73,7 @@ class C2: b: int C2(1) -C2("1") +C2("1") @dataclasses.dataclass @@ -82,7 +82,7 @@ class D1: b: int D1(1, 2) -D1("1", "2") +D1("1", "2") @dataclasses.dataclass @@ -94,13 +94,13 @@ class E1: e: int = dataclasses.field(default_factory=int) E1(1, "1") -E1("1", 1) +E1("1", 1) E1(1, "1", b"1") E1(b"1", "1", 1) E1(1, "1", b"1", 1) -E1("1", b"1", "1", "1") +E1("1", b"1", "1", "1") @dataclasses.dataclass diff --git a/python/testData/inspections/PyTypeCheckerInspection/InitializingNewType.py b/python/testData/inspections/PyTypeCheckerInspection/InitializingNewType.py index 1d80feee28ba..0bb081f75684 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/InitializingNewType.py +++ b/python/testData/inspections/PyTypeCheckerInspection/InitializingNewType.py @@ -3,10 +3,10 @@ from typing import NewType, Dict UserId = NewType("UserId", int) a = UserId(42) -b = UserId("John") +b = UserId("John") KeyValue = NewType("KeyValue", Dict[str, int]) KeyValue({"key": 13}) KeyValue(42) -KeyValue({"key1": "key2"}) +KeyValue({"key1": "key2"}) diff --git a/python/testData/inspections/PyTypeCheckerInspection/InitializingTypingNamedTuple.py b/python/testData/inspections/PyTypeCheckerInspection/InitializingTypingNamedTuple.py index de432484be6d..b02bc1a9f199 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/InitializingTypingNamedTuple.py +++ b/python/testData/inspections/PyTypeCheckerInspection/InitializingTypingNamedTuple.py @@ -27,9 +27,9 @@ MyTup7 = typing.NamedTuple("MyTup7", names=List[str], ages=List[int]) # fail -MyTup2('', '') -MyTup2(bar='', baz='') -MyTup2(baz='', bar='') +MyTup2('', '') +MyTup2(bar='', baz='') +MyTup2(baz='', bar='') # ok @@ -39,9 +39,9 @@ MyTup2(baz='', bar=5) # fail -MyTup3('', '') -MyTup3(bar='', baz='') -MyTup3(baz='', bar='') +MyTup3('', '') +MyTup3(bar='', baz='') +MyTup3(baz='', bar='') # ok @@ -51,9 +51,9 @@ MyTup3(baz='', bar=5) # fail -MyTup4('', '') -MyTup4(bar='', baz='') -MyTup4(baz='', bar='') +MyTup4('', '') +MyTup4(bar='', baz='') +MyTup4(baz='', bar='') # ok @@ -63,9 +63,9 @@ MyTup4(baz='', bar=5) # fail -MyTup5('', '') -MyTup5(bar='', baz='') -MyTup5(baz='', bar='') +MyTup5('', '') +MyTup5(bar='', baz='') +MyTup5(baz='', bar='') # ok @@ -75,8 +75,8 @@ MyTup5(baz='', bar=5) # fail -MyTup6(bar='', baz='', foo='') -MyTup6('', '', '') +MyTup6(bar='', baz='', foo='') +MyTup6('', '', '') # ok @@ -85,8 +85,8 @@ MyTup6(5, '', 5) # fail -MyTup7(names="A", ages=5) -MyTup7("A", 5) +MyTup7(names="A", ages=5) +MyTup7("A", 5) # ok diff --git a/python/testData/inspections/PyTypeCheckerInspection/MapArgumentsInOppositeOrderPy3.py b/python/testData/inspections/PyTypeCheckerInspection/MapArgumentsInOppositeOrderPy3.py index 07128b609f1c..716dd9ca9f05 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/MapArgumentsInOppositeOrderPy3.py +++ b/python/testData/inspections/PyTypeCheckerInspection/MapArgumentsInOppositeOrderPy3.py @@ -1 +1 @@ -map('foo', lambda c: 42) +map('foo', lambda c: 42) diff --git a/python/testData/inspections/PyTypeCheckerInspection/NewTypeAsParameter.py b/python/testData/inspections/PyTypeCheckerInspection/NewTypeAsParameter.py index 6f4d22f037cb..005b71e84d8e 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/NewTypeAsParameter.py +++ b/python/testData/inspections/PyTypeCheckerInspection/NewTypeAsParameter.py @@ -7,5 +7,5 @@ def get_user(user: UserId) -> str: get_user(UserId(5)) -get_user("John") +get_user("John") get_user(4) \ No newline at end of file diff --git a/python/testData/inspections/PyTypeCheckerInspection/OptionalOfBoundTypeVarInWarnings.py b/python/testData/inspections/PyTypeCheckerInspection/OptionalOfBoundTypeVarInWarnings.py index 663f4e1367cd..11925868e6df 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/OptionalOfBoundTypeVarInWarnings.py +++ b/python/testData/inspections/PyTypeCheckerInspection/OptionalOfBoundTypeVarInWarnings.py @@ -8,4 +8,4 @@ def expects_int_subclass_or_none(x: Optional[T]): pass -expects_int_subclass_or_none('foo') \ No newline at end of file +expects_int_subclass_or_none('foo') \ No newline at end of file diff --git a/python/testData/inspections/PyTypeCheckerInspection/ParametrizedBuiltinCollectionsAndTheirTypingAliasesAreEquivalent.py b/python/testData/inspections/PyTypeCheckerInspection/ParametrizedBuiltinCollectionsAndTheirTypingAliasesAreEquivalent.py index cc9fa70a52a8..fdb5765c3df6 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/ParametrizedBuiltinCollectionsAndTheirTypingAliasesAreEquivalent.py +++ b/python/testData/inspections/PyTypeCheckerInspection/ParametrizedBuiltinCollectionsAndTheirTypingAliasesAreEquivalent.py @@ -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(['a']) + expects_typing_List(['a']) def expects_typing_List(xs: List[int]): expects_builtin_list(xs) - expects_builtin_list(['a']) + expects_builtin_list(['a']) def expects_builtin_set(xs: set[int]): expects_typing_Set(xs) - expects_typing_Set({'a'}) + expects_typing_Set({'a'}) def expects_typing_Set(xs: Set[int]): expects_builtin_set(xs) - expects_builtin_set({'a'}) + expects_builtin_set({'a'}) def expects_builtin_frozenset(xs: frozenset[int]): expects_typing_FrozenSet(xs) - expects_typing_FrozenSet(frozenset(['a'])) + expects_typing_FrozenSet(frozenset(['a'])) def expects_typing_FrozenSet(xs: FrozenSet[int]): expects_builtin_frozenset(xs) - expects_builtin_frozenset(frozenset(['a'])) + expects_builtin_frozenset(frozenset(['a'])) def expects_builtin_dict(xs: dict[str, int]): expects_typing_Dict(xs) - expects_typing_Dict({42: 'a'}) + expects_typing_Dict({42: 'a'}) def expects_typing_Dict(xs: Dict[str, int]): expects_builtin_dict(xs) - expects_builtin_dict({42: 'a'}) + expects_builtin_dict({42: 'a'}) def expects_builtin_tuple(xs: tuple[str, int]): expects_typing_Tuple(xs) - expects_typing_Tuple((42, 'a')) + expects_typing_Tuple((42, 'a')) def expects_typing_Tuple(xs: Tuple[str, int]): expects_builtin_tuple(xs) - expects_builtin_tuple((42, 'a')) + expects_builtin_tuple((42, 'a')) diff --git a/python/testData/inspections/PyTypeCheckerInspection/ReAssignment.py b/python/testData/inspections/PyTypeCheckerInspection/ReAssignment.py index 44e6c5b5bf65..22dfa9fcd720 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/ReAssignment.py +++ b/python/testData/inspections/PyTypeCheckerInspection/ReAssignment.py @@ -1,8 +1,8 @@ def f(): x: int = 0 - x = 'foo' + x = 'foo' x = 1 - x = 'bar' + x = 'bar' y: str = 'foo' y = 'bar' y = 0 diff --git a/python/testData/inspections/PyTypeCheckerInspection/StructUnpackPy3/a.py b/python/testData/inspections/PyTypeCheckerInspection/StructUnpackPy3/a.py index faeb158d8f84..292b18e5d7f5 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/StructUnpackPy3/a.py +++ b/python/testData/inspections/PyTypeCheckerInspection/StructUnpackPy3/a.py @@ -1,5 +1,5 @@ from struct import Struct s = Struct('c') -s.unpack('\x00') +s.unpack('\x00') s.unpack(b'\x00') diff --git a/python/testData/inspections/PyTypeCheckerInspection/TypeDeclarationAndAssignment.py b/python/testData/inspections/PyTypeCheckerInspection/TypeDeclarationAndAssignment.py index ade52ac6a608..190347dd1f4a 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/TypeDeclarationAndAssignment.py +++ b/python/testData/inspections/PyTypeCheckerInspection/TypeDeclarationAndAssignment.py @@ -1,5 +1,5 @@ def f(): x: int - x = 'foo' + x = 'foo' y: str y = 'bar' diff --git a/python/testData/inspections/PyTypeCheckerInspection/TypedDictInReturnType.py b/python/testData/inspections/PyTypeCheckerInspection/TypedDictInReturnType.py index 9ce1cc4857bf..a7f2c9af5cec 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/TypedDictInReturnType.py +++ b/python/testData/inspections/PyTypeCheckerInspection/TypedDictInReturnType.py @@ -13,7 +13,7 @@ def b(x: int) -> Point: return {'x': 42} def c() -> Point: - return {'x': 'abc', 'y': 42} + return {'x': 'abc', 'y': 42} def d() -> Point: return {'x': 42, 'y': 42, 'k': 42} @@ -22,7 +22,7 @@ def e1(x: int): return {'x': x} def e(x: int) -> Point: - return e1(x) + return e1(x) def f1(x: int) -> Point: pass @@ -34,7 +34,7 @@ def g() -> Point: x = int(input()) y = {'x': x} if x > 0: - return y + return y elif x == 0: return Point(x=442, y=42) else: diff --git a/python/testData/inspections/PyTypeCheckerInspection/TypedDictInStub/a.py b/python/testData/inspections/PyTypeCheckerInspection/TypedDictInStub/a.py index b29e2ddad997..84b1d60b24cb 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/TypedDictInStub/a.py +++ b/python/testData/inspections/PyTypeCheckerInspection/TypedDictInStub/a.py @@ -1,3 +1,3 @@ avrora = {'name': 'Iskra', 'id': 42} rodina = {'name': 'Iskra'} -luksor = {'name': 'Iskra', 'id': '42'} \ No newline at end of file +luksor = {'name': 'Iskra', 'id': '42'} \ No newline at end of file diff --git a/python/testData/inspections/PyTypeCheckerInspection/TypingAnnotatedTypeMultiFile/a.py b/python/testData/inspections/PyTypeCheckerInspection/TypingAnnotatedTypeMultiFile/a.py index a9aab0de7c7b..07f382942efe 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/TypingAnnotatedTypeMultiFile/a.py +++ b/python/testData/inspections/PyTypeCheckerInspection/TypingAnnotatedTypeMultiFile/a.py @@ -1,5 +1,5 @@ from annotated import A -a: A = 'str' +a: A = 'str' a1: A = 42 diff --git a/python/testData/inspections/PyTypeCheckerInspection/TypingCallableCall.py b/python/testData/inspections/PyTypeCheckerInspection/TypingCallableCall.py index 4c0dd93fcc72..f054ba1515c0 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/TypingCallableCall.py +++ b/python/testData/inspections/PyTypeCheckerInspection/TypingCallableCall.py @@ -28,5 +28,5 @@ cllbl_b(1, "2") cllbl_c = baz() cllbl_c(1, "2") cllbl_c(1, 2) -cllbl_c("1", "2") +cllbl_c("1", "2") cllbl_c([], []) diff --git a/python/testData/inspections/PyTypeCheckerInspection/TypingRequiredTypeSpecificationsMultiFile/a.py b/python/testData/inspections/PyTypeCheckerInspection/TypingRequiredTypeSpecificationsMultiFile/a.py index 503eaad40fba..11e321ab82af 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/TypingRequiredTypeSpecificationsMultiFile/a.py +++ b/python/testData/inspections/PyTypeCheckerInspection/TypingRequiredTypeSpecificationsMultiFile/a.py @@ -3,4 +3,4 @@ from required import A, AlternativeSyntax a: A = {} a1: A = {'x': 42, 'y': 42} -a2: AlternativeSyntax = {'y': "str"} +a2: AlternativeSyntax = {'y': "str"} diff --git a/python/testData/inspections/PyTypeCheckerInspection/TypingTypeVarWithUnresolvedBound.py b/python/testData/inspections/PyTypeCheckerInspection/TypingTypeVarWithUnresolvedBound.py index 2786f5ce7020..de5fd2b6fee6 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/TypingTypeVarWithUnresolvedBound.py +++ b/python/testData/inspections/PyTypeCheckerInspection/TypingTypeVarWithUnresolvedBound.py @@ -8,4 +8,4 @@ def calc(a: T, b: T): pass -calc('a', 0) +calc('a', 0) diff --git a/python/testData/inspections/PyTypeCheckerInspection/WithOpenBinaryPy3.py b/python/testData/inspections/PyTypeCheckerInspection/WithOpenBinaryPy3.py index 776c23aec493..3f5960f0fa7c 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/WithOpenBinaryPy3.py +++ b/python/testData/inspections/PyTypeCheckerInspection/WithOpenBinaryPy3.py @@ -2,4 +2,4 @@ with open('foo', 'wb') as fd: fd.write(b'bar') with open('foo', 'wb') as fd: - fd.write('bar') + fd.write('bar') diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection3K/descriptorAttribute.py b/python/testData/inspections/PyUnresolvedReferencesInspection3K/descriptorAttribute.py index 83d5690cc173..19df50cbd4d4 100644 --- a/python/testData/inspections/PyUnresolvedReferencesInspection3K/descriptorAttribute.py +++ b/python/testData/inspections/PyUnresolvedReferencesInspection3K/descriptorAttribute.py @@ -25,7 +25,7 @@ class C: # Instance level c = C() c.foo.upper() -c.foo.non_existent() +c.foo.non_existent() c.bar.upper() c.bar.non_existent() c.baz.append() @@ -34,6 +34,6 @@ c.baz.non_existent() +C.foo.non_existent() C.bar.upper() C.bar.non_existent() diff --git a/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/AnnotationImportTypingAny/main_after.py b/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/AnnotationImportTypingAny/main_after.py index 288f1bb22e1a..f663ded9e3db 100644 --- a/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/AnnotationImportTypingAny/main_after.py +++ b/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/AnnotationImportTypingAny/main_after.py @@ -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 \ No newline at end of file diff --git a/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/AnnotationImportTypingUnion/main_after.py b/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/AnnotationImportTypingUnion/main_after.py index a82071c43564..1000cf807915 100644 --- a/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/AnnotationImportTypingUnion/main_after.py +++ b/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/AnnotationImportTypingUnion/main_after.py @@ -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 \ No newline at end of file diff --git a/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationLocalChainedAssignmentTarget_after.py b/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationLocalChainedAssignmentTarget_after.py index d0010fe9297f..bd837573a9ed 100644 --- a/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationLocalChainedAssignmentTarget_after.py +++ b/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationLocalChainedAssignmentTarget_after.py @@ -1,7 +1,4 @@ -from typing import LiteralString - - def func(): - var: [LiteralString] + var: [str] var = another = 'spam' var \ No newline at end of file diff --git a/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationLocalForTarget_after.py b/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationLocalForTarget_after.py index dcf5627c109c..8a3144208a9c 100644 --- a/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationLocalForTarget_after.py +++ b/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationLocalForTarget_after.py @@ -1,6 +1,3 @@ -from typing import LiteralString - - def func(): var: [LiteralString] for var in 'spam': diff --git a/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationLocalSimpleAssignmentTarget_after.py b/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationLocalSimpleAssignmentTarget_after.py index 20c561efc7d6..d4497ad25280 100644 --- a/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationLocalSimpleAssignmentTarget_after.py +++ b/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationLocalSimpleAssignmentTarget_after.py @@ -1,6 +1,3 @@ -from typing import LiteralString - - def func(): - var: [LiteralString] = 'spam' + var: [str] = 'spam' var diff --git a/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationLocalUnpackedAssignmentTarget_after.py b/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationLocalUnpackedAssignmentTarget_after.py index 773eed826c90..64f4008aad8f 100644 --- a/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationLocalUnpackedAssignmentTarget_after.py +++ b/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationLocalUnpackedAssignmentTarget_after.py @@ -1,7 +1,4 @@ -from typing import LiteralString - - def func(): - var: [LiteralString] + var: [str] var, _ = 'spam', 42 var diff --git a/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationTupleType_after.py b/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationTupleType_after.py index f7fa0b49e3af..fe382ba86b97 100644 --- a/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationTupleType_after.py +++ b/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationTupleType_after.py @@ -1,3 +1,3 @@ -from typing import Tuple, LiteralString +from typing import Tuple -var: [Tuple[int, LiteralString, None]] = (1, 'foo', None) \ No newline at end of file +var: [Tuple[int, str, None]] = (1, 'foo', None) \ No newline at end of file diff --git a/python/testData/pyi/inspections/overloadedGenerics/OverloadedGenerics.py b/python/testData/pyi/inspections/overloadedGenerics/OverloadedGenerics.py index 7b4d124cbdd2..03e14f848cb4 100644 --- a/python/testData/pyi/inspections/overloadedGenerics/OverloadedGenerics.py +++ b/python/testData/pyi/inspections/overloadedGenerics/OverloadedGenerics.py @@ -1,6 +1,6 @@ from m1 import g, Gen g(Gen(10).get(10, 10)) -g(Gen(10).get(10, 'foo')) -g(Gen('foo').get(10, 10)) -g(Gen('foo').get(10, 'foo')) +g(Gen(10).get(10, 'foo')) +g(Gen('foo').get(10, 10)) +g(Gen('foo').get(10, 'foo')) diff --git a/python/testData/pyi/inspections/overloadsWithDifferentNumberOfParameters/OverloadsWithDifferentNumberOfParameters.py b/python/testData/pyi/inspections/overloadsWithDifferentNumberOfParameters/OverloadsWithDifferentNumberOfParameters.py index 7d7db5933abb..93ff6a278cb0 100644 --- a/python/testData/pyi/inspections/overloadsWithDifferentNumberOfParameters/OverloadsWithDifferentNumberOfParameters.py +++ b/python/testData/pyi/inspections/overloadsWithDifferentNumberOfParameters/OverloadsWithDifferentNumberOfParameters.py @@ -3,26 +3,26 @@ from m1 import f, g, h def test_different_number_of_parameters(): f(5) - f("a") + f("a") f(5, "a") - f("a", "b") + f("a", "b") f(5, 6) - f("a", 5) + f("a", 5) def test_same_number_of_parameters_but_one_is_default(): g(5) - g("a") + g("a") - g("a", False) + g("a", False) g(5, 6) g(False, 5) g(5, "a") - g("a", "b") + g("a", "b") g(5, 6) - g("a", 5) + g("a", 5) 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(5, False) # fail h("a", 5) # fail - h(False, "a") # fail \ No newline at end of file + h(False, "a") # fail \ No newline at end of file diff --git a/python/testData/quickFixes/PyRemoveCallQuickFixTest/class.py b/python/testData/quickFixes/PyRemoveCallQuickFixTest/class.py index cd9e2e8d3ca6..52530e7b14d1 100644 --- a/python/testData/quickFixes/PyRemoveCallQuickFixTest/class.py +++ b/python/testData/quickFixes/PyRemoveCallQuickFixTest/class.py @@ -3,4 +3,4 @@ class A(): x = "" -b = A().x() \ No newline at end of file +b = A().x() \ No newline at end of file diff --git a/python/testData/quickFixes/PyRemoveCallQuickFixTest/decorator.py b/python/testData/quickFixes/PyRemoveCallQuickFixTest/decorator.py index 74b26f1adb69..7f8efe576fa9 100644 --- a/python/testData/quickFixes/PyRemoveCallQuickFixTest/decorator.py +++ b/python/testData/quickFixes/PyRemoveCallQuickFixTest/decorator.py @@ -5,7 +5,7 @@ def b(c): pass -@a +@a @b def foo(): pass diff --git a/python/testData/quickFixes/PyRemoveCallQuickFixTest/expression.py b/python/testData/quickFixes/PyRemoveCallQuickFixTest/expression.py index dfe279c36a9a..7b9faddb5789 100644 --- a/python/testData/quickFixes/PyRemoveCallQuickFixTest/expression.py +++ b/python/testData/quickFixes/PyRemoveCallQuickFixTest/expression.py @@ -1,4 +1,4 @@ a = "string" -b = a() \ No newline at end of file +b = a() \ No newline at end of file diff --git a/python/testData/quickdoc/ClassAttr.html b/python/testData/quickdoc/ClassAttr.html index ebc36af9568e..bd772cb1d843 100644 --- a/python/testData/quickdoc/ClassAttr.html +++ b/python/testData/quickdoc/ClassAttr.html @@ -1 +1 @@ -
Class attribute the_attr of ClassAttr.C
the_attr: LiteralString = ""
The documentation for the attribute.
\ No newline at end of file +
Class attribute the_attr of ClassAttr.C
the_attr: str = ""
The documentation for the attribute.
\ No newline at end of file diff --git a/python/testData/quickdoc/DefaultValues.html b/python/testData/quickdoc/DefaultValues.html index b9c5d29ef3e2..9a0f3c65a2c2 100644 --- a/python/testData/quickdoc/DefaultValues.html +++ b/python/testData/quickdoc/DefaultValues.html @@ -1,3 +1,3 @@
 DefaultValues.C
def method(self=42,
            foo: list[int] = [1,
2], - bar: LiteralString = "<br/>") -> None
\ No newline at end of file + bar: str = "<br/>") -> None \ No newline at end of file diff --git a/python/testData/quickdoc/HoverOverControlFlowUnion.html b/python/testData/quickdoc/HoverOverControlFlowUnion.html index ec9a6e3afe86..71244d8f5335 100644 --- a/python/testData/quickdoc/HoverOverControlFlowUnion.html +++ b/python/testData/quickdoc/HoverOverControlFlowUnion.html @@ -1 +1 @@ -Variable "x"
Inferred type: LiteralString | int \ No newline at end of file +Variable "x"
Inferred type: str | int \ No newline at end of file diff --git a/python/testData/quickdoc/InstanceAttr.html b/python/testData/quickdoc/InstanceAttr.html index f077e7ff1edf..cee843890317 100644 --- a/python/testData/quickdoc/InstanceAttr.html +++ b/python/testData/quickdoc/InstanceAttr.html @@ -1 +1 @@ -
Instance attribute foo of InstanceAttr.C
foo: LiteralString = "Foo"
The docstring for the attribute foo.
\ No newline at end of file +
Instance attribute foo of InstanceAttr.C
foo: str = "Foo"
The docstring for the attribute foo.
\ No newline at end of file diff --git a/python/testData/quickdoc/TupleTypeIsRenderedLowercased.html b/python/testData/quickdoc/TupleTypeIsRenderedLowercased.html index 6347debff730..e32b57e825bf 100644 --- a/python/testData/quickdoc/TupleTypeIsRenderedLowercased.html +++ b/python/testData/quickdoc/TupleTypeIsRenderedLowercased.html @@ -1 +1 @@ -
 TupleTypeIsRenderedLowercased
items: tuple[int, LiteralString] = (42, 'foo')
\ No newline at end of file +
 TupleTypeIsRenderedLowercased
items: tuple[int, str] = (42, 'foo')
\ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/Py3TypeTest.java b/python/testSrc/com/jetbrains/python/Py3TypeTest.java index 0b0d7d563997..df206183d8cf 100644 --- a/python/testSrc/com/jetbrains/python/Py3TypeTest.java +++ b/python/testSrc/com/jetbrains/python/Py3TypeTest.java @@ -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]", diff --git a/python/testSrc/com/jetbrains/python/PyDecoratedFunctionTypeProviderTest.java b/python/testSrc/com/jetbrains/python/PyDecoratedFunctionTypeProviderTest.java index d650f05add2a..061108affef8 100644 --- a/python/testSrc/com/jetbrains/python/PyDecoratedFunctionTypeProviderTest.java +++ b/python/testSrc/com/jetbrains/python/PyDecoratedFunctionTypeProviderTest.java @@ -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 diff --git a/python/testSrc/com/jetbrains/python/PyParameterInfoTest.java b/python/testSrc/com/jetbrains/python/PyParameterInfoTest.java index 8164b24e43cd..77861d343eec 100644 --- a/python/testSrc/com/jetbrains/python/PyParameterInfoTest.java +++ b/python/testSrc/com/jetbrains/python/PyParameterInfoTest.java @@ -433,8 +433,8 @@ public class PyParameterInfoTest extends LightMarkedTestCase { public void testMultilineStringDefault() { final int offset = loadTest(1).get("").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("").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("").getTextOffset()).check("x, z: int = ...", new String[]{"x, "}); feignCtrlP(marks.get("").getTextOffset()).check("x, y, z: list = ...", new String[]{"x, "}); feignCtrlP(marks.get("").getTextOffset()).check("x, y: int = ...", new String[]{"x, "}); - feignCtrlP(marks.get("").getTextOffset()).check("x, y: LiteralString = ...", new String[]{"x, "}); + feignCtrlP(marks.get("").getTextOffset()).check("x, y: str = ...", new String[]{"x, "}); feignCtrlP(marks.get("").getTextOffset()).check("x: int = ...", new String[]{"x: int = ..."}); feignCtrlP(marks.get("").getTextOffset()).check("x, y, z: list = ...", new String[]{"x, "}); } diff --git a/python/testSrc/com/jetbrains/python/PyTypeTest.java b/python/testSrc/com/jetbrains/python/PyTypeTest.java index 846a0e291b77..577f9e9bebac 100644 --- a/python/testSrc/com/jetbrains/python/PyTypeTest.java +++ b/python/testSrc/com/jetbrains/python/PyTypeTest.java @@ -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 diff --git a/python/testSrc/com/jetbrains/python/PyTypingTest.java b/python/testSrc/com/jetbrains/python/PyTypingTest.java index c322ed902ebd..9b3e2acb77e2 100644 --- a/python/testSrc/com/jetbrains/python/PyTypingTest.java +++ b/python/testSrc/com/jetbrains/python/PyTypingTest.java @@ -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 diff --git a/python/testSrc/com/jetbrains/python/inspections/Py3TypeCheckerInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/Py3TypeCheckerInspectionTest.java index 62a0ee0a45a0..0433ed006ced 100644 --- a/python/testSrc/com/jetbrains/python/inspections/Py3TypeCheckerInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/Py3TypeCheckerInspectionTest.java @@ -298,7 +298,7 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase { y = attr.ib(default=0) z = attr.ib(default=attr.Factory(list)) \s - Weak1(1, "str", 2) + Weak1(1, "str", 2) @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, "str", ["str"])""" + Strong(1, "str", ["str"])""" ) ); } @@ -425,9 +425,9 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase { doTestByText(""" from typing import Annotated A = Annotated[bool, 'Some constraint'] - a: A = 'str' + a: A = 'str' b: A = True - c: Annotated[bool, 'Some constraint'] = 'str' + c: Annotated[bool, 'Some constraint'] = 'str' 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("42") + expr = Y(a, '1').f("42") """); } @@ -620,7 +620,7 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase { def add(x: Callable[P, int]) -> Callable[Concatenate[str, P], bool]: ... - add(bar)("42", "42", True)"""); + add(bar)("42", "42", 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, "A", 1) + res3 = twice(a_int_b_str, "A", 1) - res4 = twice(a_int_b_str, b=1, a="A")"""); + res4 = twice(a_int_b_str, b=1, a="A")"""); } // PY-50403 @@ -1086,13 +1086,13 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase { myClass.foo(subClass) myClass.foo(42) myClass.foo(None) - myClass.foo("") + myClass.foo("") subClass.foo(myClass) subClass.foo(subClass) subClass.foo(42) subClass.foo(None) - subClass.foo("")"""); + subClass.foo("")"""); } // PY-53104 @@ -1287,7 +1287,7 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase { foo(1, bar, args=(0, 'foo')) - foo(1, bar, args=('foo', 0)) + foo(1, bar, args=('foo', 0)) """); } @@ -1397,9 +1397,9 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase { foo('', True, 42, c=True, b='') foo('', b='', c=True) - foo('', '', b='', c=True) - foo('', '', [False], b='', c=True) - foo('', '', '', '', 1.1, b='', c=True) + foo('', '', b='', c=True) + foo('', '', [False], b='', c=True) + foo('', '', '', '', 1.1, b='', c=True) """); } @@ -1420,13 +1420,13 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase { foo((), '', 1, b='') foo(([], {}), '', [], {}, 1, b='') - foo(('', 1), b='') - foo(('', 1), '', '', '', 1, b='') - foo((1,1), '', 1, 1, b='') - foo(('',), '', 1, 1, b='') + foo(('', 1), b='') + foo(('', 1), '', '', '', 1, b='') + foo((1,1), '', 1, 1, b='') + foo(('',), '', 1, 1, b='') x: Any - foo((), '', 42, x, b='') - foo(([], {}), '', [], {}, b='') + foo((), '', 42, x, b='') + foo(([], {}), '', [], {}, b='') """); } @@ -1465,13 +1465,13 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase { foo((), '', 1, b='') foo(([], {}), '', [], {}, 1, b='') - foo(('', 1), b='') - foo(('', 1), '', '', '', 1, b='') - foo((1,1), '', 1, 1, b='') - foo(('',), '', 1, 1, b='') + foo(('', 1), b='') + foo(('', 1), '', '', '', 1, b='') + foo((1,1), '', 1, 1, b='') + foo(('',), '', 1, 1, b='') x: Any - foo((), '', 42, x, b='') - foo(([], {}), '', [], {}, b='') + foo((), '', 42, x, b='') + foo(([], {}), '', [], {}, b='') """); } @@ -1492,13 +1492,13 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase { foo((), '', 1, b='') foo(([], {}), '', [], {}, 1, b='') - foo(('', 1), b='') - foo(('', 1), '', '', '', 1, b='') - foo((1,1), '', 1, 1, b='') - foo(('',), '', 1, 1, b='') + foo(('', 1), b='') + foo(('', 1), '', '', '', 1, b='') + foo((1,1), '', 1, 1, b='') + foo(('',), '', 1, 1, b='') x: Any - foo((), '', 42, x, b='') - foo(([], {}), '', [], {}, b='') + foo((), '', 42, x, b='') + foo(([], {}), '', [], {}, b='') """); } @@ -1515,8 +1515,8 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase { foo(1) foo(1, 2, 3) - foo('') - foo(1, '') + foo('') + foo(1, '') """); } @@ -1633,7 +1633,7 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase { IntTuple = tuple[int, *Ts] - c: IntTuple[()] = (1, "") + c: IntTuple[()] = (1, "") """); } @@ -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 = s literal_string: LiteralString = "hello" """); @@ -1828,6 +1827,7 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase { plain_string: str expect_literal_string(literal_string + plain_string) + expect_literal_string(plain_string + literal_string) """); } @@ -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, plain_string) """); } diff --git a/python/testSrc/com/jetbrains/python/inspections/PyTypeCheckerInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyTypeCheckerInspectionTest.java index 6b8d87ee4535..70f6a2fe1716 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyTypeCheckerInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyTypeCheckerInspectionTest.java @@ -779,7 +779,7 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase { F = TypeVar('F', bound=int) def deco(func: F) -> F: - return """"") + return """"") ); } @@ -961,7 +961,7 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase { a: Literal["22"] = f"22" b: Literal["22"] = f"32" two = "2" - c: Literal["22"] = f"2{two}"""") + c: Literal["22"] = f"2{two}"""") ); } @@ -990,7 +990,7 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase { pass def foo(cb: Callback[int]): - cb("42")""") + cb("42")""") ); } @@ -1057,17 +1057,17 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase { class Point(TypedDict): x: int y: int - p1: Point = {'x': 0, 'y': 'a'} - p2: NotPoint = {'x': 'x', 'y': 42} + p1: Point = {'x': 0, 'y': 'a'} + p2: NotPoint = {'x': 'x', 'y': 42} p3: Point = p2 p4: Point = {} p5: Point = {'x': 0, 'y': 0, 'z': 123, 'k': 6} p6: Point = {'y': 123} p7: Movie = dict(name='Alien', year=1979) - p8: Movie = dict(name='Alien', year='1979') + p8: Movie = dict(name='Alien', year='1979') p9: Movie = dict(name='Alien', year=1979, director='Ridley Scott') p10 = {'x': 'x', 'y': 42, 'z': 42} - p11: Point = p10""" + p11: Point = p10""" )); } @@ -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='1979') + m2: Movie = dict(name='Alien', year='1979') m3: Movie = typing.cast(Movie, dict(zip(['name', 'year'], ['Alien', 1979]))) - m4: Movie = {'name': 'Alien', 'year': '1979'} + m4: Movie = {'name': 'Alien', 'year': '1979'} 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']['i'] - s2: str = movie2['address']['i'] + s: str = movie['address']['i'] + s2: str = movie2['address']['i'] """)); } @@ -1414,13 +1414,13 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase { z = {'foo': 'bar'} n = {"foo": "", "quux": 3} f(y) - f(n) + f(n) f(z) f(x=y) - f(x=n) + f(x=n) f(x=z) z2: C = y - z2: C = n + z2: C = n 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': 'baz'}""") + b: Foo = {'foo': 'baz'}""") ); } @@ -1473,8 +1473,8 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase { 0: 'zero', } } - s: HardDict = {'a': 'xx', 'd': t} - s1: HardDict = t + s: HardDict = {'a': 'xx', 'd': t} + s1: HardDict = t t1 = { 'a': 'xx', 'd': { @@ -1482,8 +1482,8 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase { 'd': {} } } - s2: HardDict = {'a': 'xx', 'd': t1} - s3: HardDict = t1 + s2: HardDict = {'a': 'xx', 'd': t1} + s3: HardDict = t1 s4: HardDict = { '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": 1, "group": [], "some_other_key": ''}""") + group: GroupWithOtherKey[str, int] = {"key": 1, "group": [], "some_other_key": ''}""") ); } diff --git a/python/testSrc/com/jetbrains/python/inspections/PyTypedDictInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyTypedDictInspectionTest.java index 07a7171e2394..27f95921f37a 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyTypedDictInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyTypedDictInspectionTest.java @@ -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':'2004', 'based_on': 'book'}) - m.update(name=1984, year=1984, based_on_book='yes') + m.update({'name':'Garden State', 'year':'2004', 'based_on': 'book'}) + m.update(name=1984, year=1984, based_on_book='yes') m.update([('name',1984), ('year',None)])"""); } @@ -214,7 +214,7 @@ public class PyTypedDictInspectionTest extends PyInspectionTestCase { year: int movie = Movie() movie2 = Movie2() - movie['year'], movie2['year'] = '1984', '1984' + movie['year'], movie2['year'] = '1984', '1984' """); } diff --git a/python/testSrc/com/jetbrains/python/inspections/typeignore/TypeIgnoreInspectionSuppressorTest.kt b/python/testSrc/com/jetbrains/python/inspections/typeignore/TypeIgnoreInspectionSuppressorTest.kt index 2839b599ba7b..492c5c9b02b7 100644 --- a/python/testSrc/com/jetbrains/python/inspections/typeignore/TypeIgnoreInspectionSuppressorTest.kt +++ b/python/testSrc/com/jetbrains/python/inspections/typeignore/TypeIgnoreInspectionSuppressorTest.kt @@ -81,7 +81,7 @@ class TypeIgnoreInspectionSuppressorTest : PyTestCase() { fun testIgnoreType() { doTestByText(""" print(2 + 'foo') # type: ignore - print(2 + 'foo') + print(2 + 'foo') """) }