diff --git a/conformance/results/mypy/literals_literalstring.toml b/conformance/results/mypy/literals_literalstring.toml index 0e7ae143a..b6554e3f6 100644 --- a/conformance/results/mypy/literals_literalstring.toml +++ b/conformance/results/mypy/literals_literalstring.toml @@ -8,18 +8,15 @@ literals_literalstring.py:37: error: Parameter 1 of Literal[...] is invalid [va literals_literalstring.py:43: error: Incompatible types in assignment (expression has type "Literal['two']", variable has type "Literal['']") [assignment] literals_literalstring.py:74: error: Incompatible types in assignment (expression has type "int", variable has type "str") [assignment] literals_literalstring.py:75: error: Incompatible types in assignment (expression has type "bytes", variable has type "str") [assignment] -literals_literalstring.py:142: error: Overloaded function signatures 1 and 2 overlap with incompatible return types [overload-overlap] -literals_literalstring.py:142: error: Overloaded function signatures 1 and 3 overlap with incompatible return types [overload-overlap] -literals_literalstring.py:152: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader [misc] -literals_literalstring.py:162: error: Expression is of type "bool", not "str" [assert-type] +literals_literalstring.py:157: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader [misc] +literals_literalstring.py:167: error: Expression is of type "B", not "A" [assert-type] """ conformance_automated = "Fail" errors_diff = """ Line 66: Expected 1 errors Line 120: Expected 1 errors Line 134: Expected 1 errors -Line 166: Expected 1 errors -Line 142: Unexpected errors ['literals_literalstring.py:142: error: Overloaded function signatures 1 and 2 overlap with incompatible return types [overload-overlap]', 'literals_literalstring.py:142: error: Overloaded function signatures 1 and 3 overlap with incompatible return types [overload-overlap]'] -Line 152: Unexpected errors ["literals_literalstring.py:152: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader [misc]"] -Line 162: Unexpected errors ['literals_literalstring.py:162: error: Expression is of type "bool", not "str" [assert-type]'] +Line 171: Expected 1 errors +Line 157: Unexpected errors ["literals_literalstring.py:157: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader [misc]"] +Line 167: Unexpected errors ['literals_literalstring.py:167: error: Expression is of type "B", not "A" [assert-type]'] """ diff --git a/conformance/results/pyre/literals_literalstring.toml b/conformance/results/pyre/literals_literalstring.toml index f7c601683..c735a90ca 100644 --- a/conformance/results/pyre/literals_literalstring.toml +++ b/conformance/results/pyre/literals_literalstring.toml @@ -9,7 +9,7 @@ literals_literalstring.py:74:4 Incompatible variable type [9]: x3 is declared to literals_literalstring.py:75:4 Incompatible variable type [9]: x4 is declared to have type `typing_extensions.LiteralString` but is used as type `typing_extensions.Literal[b'test']`. literals_literalstring.py:120:21 Incompatible parameter type [6]: In call `literal_identity`, for 1st positional argument, expected `Variable[TLiteral (bound to typing_extensions.LiteralString)]` but got `str`. literals_literalstring.py:134:50 Incompatible parameter type [6]: In call `Container.__init__`, for 1st positional argument, expected `Variable[T (bound to typing_extensions.LiteralString)]` but got `str`. -literals_literalstring.py:166:4 Incompatible variable type [9]: x1 is declared to have type `List[str]` but is used as type `List[typing_extensions.LiteralString]`. +literals_literalstring.py:171:4 Incompatible variable type [9]: x1 is declared to have type `List[str]` but is used as type `List[typing_extensions.LiteralString]`. """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/literals_literalstring.toml b/conformance/results/pyright/literals_literalstring.toml index 2e42e81ec..4c73a0a0f 100644 --- a/conformance/results/pyright/literals_literalstring.toml +++ b/conformance/results/pyright/literals_literalstring.toml @@ -16,14 +16,11 @@ literals_literalstring.py:120:22 - error: Argument of type "str" cannot be assig literals_literalstring.py:134:51 - error: Argument of type "str" cannot be assigned to parameter "value" of type "T@Container" in function "__init__"   Type "str" cannot be assigned to type "LiteralString"     "str" is incompatible with "LiteralString" (reportArgumentType) -literals_literalstring.py:142:5 - error: Overload 1 for "func8" overlaps overload 2 and returns an incompatible type (reportOverlappingOverload) -literals_literalstring.py:142:5 - error: Overload 1 for "func8" overlaps overload 3 and returns an incompatible type (reportOverlappingOverload) -literals_literalstring.py:166:21 - error: Expression of type "list[LiteralString]" cannot be assigned to declared type "list[str]" +literals_literalstring.py:171:21 - error: Expression of type "list[LiteralString]" cannot be assigned to declared type "list[str]"   "list[LiteralString]" is incompatible with "list[str]"     Type parameter "_T@list" is invariant, but "LiteralString" is not the same as "str"     Consider switching from "list" to "Sequence" which is covariant (reportAssignmentType) """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 142: Unexpected errors ['literals_literalstring.py:142:5 - error: Overload 1 for "func8" overlaps overload 2 and returns an incompatible type (reportOverlappingOverload)', 'literals_literalstring.py:142:5 - error: Overload 1 for "func8" overlaps overload 3 and returns an incompatible type (reportOverlappingOverload)'] """ diff --git a/conformance/results/pytype/literals_literalstring.toml b/conformance/results/pytype/literals_literalstring.toml index 489e55fd8..32d16477f 100644 --- a/conformance/results/pytype/literals_literalstring.toml +++ b/conformance/results/pytype/literals_literalstring.toml @@ -10,19 +10,22 @@ File "literals_literalstring.py", line 37, in : Invalid type annotation File "literals_literalstring.py", line 43, in func1: Type annotation for x2 does not match type of assignment [annotation-type-mismatch] File "literals_literalstring.py", line 74, in func2: Type annotation for x3 does not match type of assignment [annotation-type-mismatch] File "literals_literalstring.py", line 75, in func2: Type annotation for x4 does not match type of assignment [annotation-type-mismatch] -File "literals_literalstring.py", line 157, in func8: bad return type [bad-return-type] +File "literals_literalstring.py", line 162, in func8: bad return type [bad-return-type] Called from (traceback): - line 160, in current file -File "literals_literalstring.py", line 162, in : bool [assert-type] + line 166, in current file +File "literals_literalstring.py", line 162, in func8: bad return type [bad-return-type] +Called from (traceback): + line 165, in current file +File "literals_literalstring.py", line 167, in : B [assert-type] """ conformance_automated = "Fail" errors_diff = """ Line 66: Expected 1 errors Line 120: Expected 1 errors Line 134: Expected 1 errors -Line 166: Expected 1 errors +Line 171: Expected 1 errors Line 8: Unexpected errors ['File "literals_literalstring.py", line 8, in : typing.LiteralString not supported yet [not-supported-yet]'] Line 24: Unexpected errors ['File "literals_literalstring.py", line 24, in my_function: bad return type [bad-return-type]'] -Line 157: Unexpected errors ['File "literals_literalstring.py", line 157, in func8: bad return type [bad-return-type]'] -Line 162: Unexpected errors ['File "literals_literalstring.py", line 162, in : bool [assert-type]'] +Line 162: Unexpected errors ['File "literals_literalstring.py", line 162, in func8: bad return type [bad-return-type]', 'File "literals_literalstring.py", line 162, in func8: bad return type [bad-return-type]'] +Line 167: Unexpected errors ['File "literals_literalstring.py", line 167, in : B [assert-type]'] """ diff --git a/conformance/tests/literals_literalstring.py b/conformance/tests/literals_literalstring.py index 2c9754b46..25461dd11 100644 --- a/conformance/tests/literals_literalstring.py +++ b/conformance/tests/literals_literalstring.py @@ -138,18 +138,23 @@ def func7(s: str): xs: list[LiteralString] = ["foo", "bar", "baz"] +class A: pass +class B(A): pass +class C(B): pass + + @overload -def func8(x: Literal["foo"]) -> int: +def func8(x: Literal["foo"]) -> C: ... @overload -def func8(x: LiteralString) -> bool: +def func8(x: LiteralString) -> B: ... @overload -def func8(x: str) -> str: +def func8(x: str) -> A: ... @@ -157,9 +162,9 @@ def func8(x: Any) -> Any: ... -assert_type(func8("foo"), int) # First overload -assert_type(func8("bar"), bool) # Second overload -assert_type(func8(str(1)), str) # Third overload +assert_type(func8("foo"), C) # First overload +assert_type(func8("bar"), B) # Second overload +assert_type(func8(str(1)), A) # Third overload def func9(val: list[LiteralString]):