Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conformance tests: Fix tuples_unpacked.py #1703

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions conformance/results/mypy/tuples_unpacked.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ notes = """
"""
output = """
tuples_unpacked.py: error: More than one Unpack in a type is not allowed [misc]
tuples_unpacked.py:58: error: More than one Unpack in a type is not allowed [misc]
tuples_unpacked.py:59: error: More than one Unpack in a type is not allowed [misc]
"""
conformance_automated = "Fail"
errors_diff = """
Line 31: Expected 1 errors
Line 32: Expected 1 errors
Line 39: Expected 1 errors
Line 40: Expected 1 errors
Line 50: Expected 1 errors
Line 60: Expected 1 errors
Line 41: Expected 1 errors
Line 51: Expected 1 errors
Line 61: Expected 1 errors
"""
38 changes: 21 additions & 17 deletions conformance/results/pyre/tuples_unpacked.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,34 @@ tuples_unpacked.py:25:13 Invalid type [31]: Expression `tuple[(int, *tuple[(bool
tuples_unpacked.py:26:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[Type[int], *Tuple[typing.Any, ...], Type[str]]`.
tuples_unpacked.py:26:25 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.Type[tuple[Variable[_T_co](covariant)]]`.
tuples_unpacked.py:26:37 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[bool], typing.Any]`.
tuples_unpacked.py:31:6 Invalid type [31]: Expression `tuple[(*tuple[int], *tuple[int])]` is not a valid type.
tuples_unpacked.py:32:6 Invalid type [31]: Expression `tuple[(*tuple[(int, ...)], *tuple[int])]` is not a valid type.
tuples_unpacked.py:37:4 Invalid type [31]: Expression `tuple[(*tuple[str], *tuple[str])]` is not a valid type.
tuples_unpacked.py:38:4 Invalid type [31]: Expression `tuple[(*tuple[(str, *tuple[(str, ...)])])]` is not a valid type.
tuples_unpacked.py:39:4 Invalid type [31]: Expression `tuple[(*tuple[(str, ...)], *tuple[(int, ...)])]` is not a valid type.
tuples_unpacked.py:40:4 Invalid type [31]: Expression `tuple[(*tuple[(str, *tuple[(str, ...)])], *tuple[(int, ...)])]` is not a valid type.
tuples_unpacked.py:48:13 Invalid type [31]: Expression `tuple[(*$local_tuples_unpacked$Ts)]` is not a valid type.
tuples_unpacked.py:49:8 Invalid type [31]: Expression `tuple[(*tuple[str], *$local_tuples_unpacked$Ts)]` is not a valid type.
tuples_unpacked.py:50:8 Invalid type [31]: Expression `tuple[(*tuple[(str, ...)], *$local_tuples_unpacked$Ts)]` is not a valid type.
tuples_unpacked.py:56:5 Undefined or invalid type [11]: Annotation `Unpack` is not defined as a type.
tuples_unpacked.py:31:4 Invalid type [31]: Expression `tuple[(*tuple[int], *tuple[int])]` is not a valid type.
tuples_unpacked.py:32:22 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[int], Type[int]]`.
tuples_unpacked.py:33:4 Invalid type [31]: Expression `tuple[(*tuple[(int, ...)], *tuple[int])]` is not a valid type.
tuples_unpacked.py:38:4 Invalid type [31]: Expression `tuple[(*tuple[str], *tuple[str])]` is not a valid type.
tuples_unpacked.py:39:4 Invalid type [31]: Expression `tuple[(*tuple[(str, *tuple[(str, ...)])])]` is not a valid type.
tuples_unpacked.py:40:4 Invalid type [31]: Expression `tuple[(*tuple[(str, ...)], *tuple[(int, ...)])]` is not a valid type.
tuples_unpacked.py:41:4 Invalid type [31]: Expression `tuple[(*tuple[(str, *tuple[(str, ...)])], *tuple[(int, ...)])]` is not a valid type.
tuples_unpacked.py:49:13 Invalid type [31]: Expression `tuple[(*$local_tuples_unpacked$Ts)]` is not a valid type.
tuples_unpacked.py:50:8 Invalid type [31]: Expression `tuple[(*tuple[str], *$local_tuples_unpacked$Ts)]` is not a valid type.
tuples_unpacked.py:51:8 Invalid type [31]: Expression `tuple[(*tuple[(str, ...)], *$local_tuples_unpacked$Ts)]` is not a valid type.
tuples_unpacked.py:57:5 Undefined or invalid type [11]: Annotation `Unpack` is not defined as a type.
"""
conformance_automated = "Fail"
errors_diff = """
Line 58: Expected 1 errors
Line 60: Expected 1 errors
Line 59: Expected 1 errors
Line 61: Expected 1 errors
Line 16: Unexpected errors ['tuples_unpacked.py:16:13 Invalid type [31]: Expression `tuple[(int, *tuple[(bool, bool)], str)]` is not a valid type.']
Line 17: Unexpected errors ['tuples_unpacked.py:17:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[int], Type[bool], Type[bool], Type[str]]`.']
Line 18: Unexpected errors ['tuples_unpacked.py:18:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[*Tuple[typing.Any, ...], Type[bool], Type[str]]`.', 'tuples_unpacked.py:18:25 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.Type[tuple[Variable[_T_co](covariant)]]`.', 'tuples_unpacked.py:18:32 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[int], Type[bool]]`.']
Line 19: Unexpected errors ['tuples_unpacked.py:19:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[Type[int], Type[bool], *Tuple[typing.Any, ...]]`.', 'tuples_unpacked.py:19:25 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.Type[tuple[Variable[_T_co](covariant)]]`.', 'tuples_unpacked.py:19:43 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[bool], Type[str]]`.']
Line 25: Unexpected errors ['tuples_unpacked.py:25:13 Invalid type [31]: Expression `tuple[(int, *tuple[(bool, ...)], str)]` is not a valid type.']
Line 26: Unexpected errors ['tuples_unpacked.py:26:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[Type[int], *Tuple[typing.Any, ...], Type[str]]`.', 'tuples_unpacked.py:26:25 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.Type[tuple[Variable[_T_co](covariant)]]`.', 'tuples_unpacked.py:26:37 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[bool], typing.Any]`.']
Line 37: Unexpected errors ['tuples_unpacked.py:37:4 Invalid type [31]: Expression `tuple[(*tuple[str], *tuple[str])]` is not a valid type.']
Line 38: Unexpected errors ['tuples_unpacked.py:38:4 Invalid type [31]: Expression `tuple[(*tuple[(str, *tuple[(str, ...)])])]` is not a valid type.']
Line 48: Unexpected errors ['tuples_unpacked.py:48:13 Invalid type [31]: Expression `tuple[(*$local_tuples_unpacked$Ts)]` is not a valid type.']
Line 49: Unexpected errors ['tuples_unpacked.py:49:8 Invalid type [31]: Expression `tuple[(*tuple[str], *$local_tuples_unpacked$Ts)]` is not a valid type.']
Line 56: Unexpected errors ['tuples_unpacked.py:56:5 Undefined or invalid type [11]: Annotation `Unpack` is not defined as a type.']
Line 31: Unexpected errors ['tuples_unpacked.py:31:4 Invalid type [31]: Expression `tuple[(*tuple[int], *tuple[int])]` is not a valid type.']
Line 32: Unexpected errors ['tuples_unpacked.py:32:22 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[int], Type[int]]`.']
Line 33: Unexpected errors ['tuples_unpacked.py:33:4 Invalid type [31]: Expression `tuple[(*tuple[(int, ...)], *tuple[int])]` is not a valid type.']
Line 38: Unexpected errors ['tuples_unpacked.py:38:4 Invalid type [31]: Expression `tuple[(*tuple[str], *tuple[str])]` is not a valid type.']
Line 39: Unexpected errors ['tuples_unpacked.py:39:4 Invalid type [31]: Expression `tuple[(*tuple[(str, *tuple[(str, ...)])])]` is not a valid type.']
Line 49: Unexpected errors ['tuples_unpacked.py:49:13 Invalid type [31]: Expression `tuple[(*$local_tuples_unpacked$Ts)]` is not a valid type.']
Line 50: Unexpected errors ['tuples_unpacked.py:50:8 Invalid type [31]: Expression `tuple[(*tuple[str], *$local_tuples_unpacked$Ts)]` is not a valid type.']
Line 57: Unexpected errors ['tuples_unpacked.py:57:5 Undefined or invalid type [11]: Annotation `Unpack` is not defined as a type.']
"""
14 changes: 6 additions & 8 deletions conformance/results/pyright/tuples_unpacked.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
conformant = "Pass"
output = """
tuples_unpacked.py:39:30 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple
tuples_unpacked.py:40:43 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple
tuples_unpacked.py:50:34 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple
tuples_unpacked.py:58:37 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple
tuples_unpacked.py:60:50 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple
tuples_unpacked.py:40:30 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple
tuples_unpacked.py:41:43 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple
tuples_unpacked.py:51:34 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple
tuples_unpacked.py:59:37 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple
tuples_unpacked.py:61:50 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple
"""
conformance_automated = "Fail"
conformance_automated = "Pass"
errors_diff = """
Line 31: Expected 1 errors
Line 32: Expected 1 errors
"""
38 changes: 22 additions & 16 deletions conformance/results/pytype/tuples_unpacked.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,42 @@ File "tuples_unpacked.py", line 18, in func1: Invalid type annotation '<instance
File "tuples_unpacked.py", line 19, in func1: Invalid type annotation '<instance of tuple>' [invalid-annotation]
File "tuples_unpacked.py", line 25, in <module>: Invalid type annotation '<instance of tuple>' [invalid-annotation]
File "tuples_unpacked.py", line 26, in func2: Invalid type annotation '<instance of tuple>' [invalid-annotation]
File "tuples_unpacked.py", line 31, in <module>: Type annotation for u1 does not match type of assignment [annotation-type-mismatch]
File "tuples_unpacked.py", line 31, in <module>: Invalid type annotation 'tuple[*tuple[int], *tuple[int]]' [invalid-annotation]
File "tuples_unpacked.py", line 31, in <module>: Invalid type annotation '<instance of tuple>' [invalid-annotation]
File "tuples_unpacked.py", line 31, in <module>: Function list.extend was called with the wrong arguments [wrong-arg-types]
File "tuples_unpacked.py", line 32, in <module>: Invalid type annotation '<instance of tuple>' [invalid-annotation]
File "tuples_unpacked.py", line 32, in <module>: Function list.extend was called with the wrong arguments [wrong-arg-types]
File "tuples_unpacked.py", line 37, in <module>: Invalid type annotation '<instance of tuple>' [invalid-annotation]
File "tuples_unpacked.py", line 37, in <module>: Function list.extend was called with the wrong arguments [wrong-arg-types]
File "tuples_unpacked.py", line 32, in <module>: Tuple[Any] [assert-type]
File "tuples_unpacked.py", line 33, in <module>: Invalid type annotation '<instance of tuple>' [invalid-annotation]
File "tuples_unpacked.py", line 33, in <module>: Function list.extend was called with the wrong arguments [wrong-arg-types]
File "tuples_unpacked.py", line 38, in <module>: Invalid type annotation '<instance of tuple>' [invalid-annotation]
File "tuples_unpacked.py", line 38, in <module>: Function list.extend was called with the wrong arguments [wrong-arg-types]
File "tuples_unpacked.py", line 39, in <module>: Invalid type annotation '<instance of tuple>' [invalid-annotation]
File "tuples_unpacked.py", line 39, in <module>: Function list.extend was called with the wrong arguments [wrong-arg-types]
File "tuples_unpacked.py", line 40, in <module>: Invalid type annotation '<instance of tuple>' [invalid-annotation]
File "tuples_unpacked.py", line 40, in <module>: Function list.extend was called with the wrong arguments [wrong-arg-types]
File "tuples_unpacked.py", line 45, in <module>: Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count]
File "tuples_unpacked.py", line 48, in <module>: Invalid type annotation '<instance of Tuple[nothing, ...]>' [invalid-annotation]
File "tuples_unpacked.py", line 49, in func3: Invalid type annotation 'tuple[*tuple[str], *Ts]' [invalid-annotation]
File "tuples_unpacked.py", line 50, in func3: Invalid type annotation 'tuple[*tuple[str, ...], *Ts]' [invalid-annotation]
File "tuples_unpacked.py", line 41, in <module>: Invalid type annotation '<instance of tuple>' [invalid-annotation]
File "tuples_unpacked.py", line 41, in <module>: Function list.extend was called with the wrong arguments [wrong-arg-types]
File "tuples_unpacked.py", line 46, in <module>: Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count]
File "tuples_unpacked.py", line 49, in <module>: Invalid type annotation '<instance of Tuple[nothing, ...]>' [invalid-annotation]
File "tuples_unpacked.py", line 50, in func3: Invalid type annotation 'tuple[*tuple[str], *Ts]' [invalid-annotation]
File "tuples_unpacked.py", line 51, in func3: Invalid type annotation 'tuple[*tuple[str, ...], *Ts]' [invalid-annotation]
"""
conformance_automated = "Fail"
errors_diff = """
Line 58: Expected 1 errors
Line 60: Expected 1 errors
Line 59: Expected 1 errors
Line 61: Expected 1 errors
Line 13: Unexpected errors ['File "tuples_unpacked.py", line 13, in <module>: typing.Unpack not supported yet [not-supported-yet]', 'File "tuples_unpacked.py", line 13, in <module>: typing.TypeVarTuple not supported yet [not-supported-yet]']
Line 16: Unexpected errors ['File "tuples_unpacked.py", line 16, in <module>: Invalid type annotation \\'<instance of tuple>\\' [invalid-annotation]']
Line 17: Unexpected errors ['File "tuples_unpacked.py", line 17, in func1: Tuple[Any] [assert-type]']
Line 18: Unexpected errors ['File "tuples_unpacked.py", line 18, in func1: Invalid type annotation \\'<instance of tuple>\\' [invalid-annotation]']
Line 19: Unexpected errors ['File "tuples_unpacked.py", line 19, in func1: Invalid type annotation \\'<instance of tuple>\\' [invalid-annotation]']
Line 25: Unexpected errors ['File "tuples_unpacked.py", line 25, in <module>: Invalid type annotation \\'<instance of tuple>\\' [invalid-annotation]']
Line 26: Unexpected errors ['File "tuples_unpacked.py", line 26, in func2: Invalid type annotation \\'<instance of tuple>\\' [invalid-annotation]']
Line 37: Unexpected errors ['File "tuples_unpacked.py", line 37, in <module>: Invalid type annotation \\'<instance of tuple>\\' [invalid-annotation]', 'File "tuples_unpacked.py", line 37, in <module>: Function list.extend was called with the wrong arguments [wrong-arg-types]']
Line 38: Unexpected errors ['File "tuples_unpacked.py", line 38, in <module>: Invalid type annotation \\'<instance of tuple>\\' [invalid-annotation]']
Line 45: Unexpected errors ['File "tuples_unpacked.py", line 45, in <module>: Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count]']
Line 48: Unexpected errors ['File "tuples_unpacked.py", line 48, in <module>: Invalid type annotation \\'<instance of Tuple[nothing, ...]>\\' [invalid-annotation]']
Line 49: Unexpected errors ['File "tuples_unpacked.py", line 49, in func3: Invalid type annotation \\'tuple[*tuple[str], *Ts]\\' [invalid-annotation]']
Line 31: Unexpected errors ['File "tuples_unpacked.py", line 31, in <module>: Type annotation for u1 does not match type of assignment [annotation-type-mismatch]', 'File "tuples_unpacked.py", line 31, in <module>: Invalid type annotation \\'tuple[*tuple[int], *tuple[int]]\\' [invalid-annotation]', 'File "tuples_unpacked.py", line 31, in <module>: Invalid type annotation \\'<instance of tuple>\\' [invalid-annotation]', 'File "tuples_unpacked.py", line 31, in <module>: Function list.extend was called with the wrong arguments [wrong-arg-types]']
Line 32: Unexpected errors ['File "tuples_unpacked.py", line 32, in <module>: Tuple[Any] [assert-type]']
Line 33: Unexpected errors ['File "tuples_unpacked.py", line 33, in <module>: Invalid type annotation \\'<instance of tuple>\\' [invalid-annotation]', 'File "tuples_unpacked.py", line 33, in <module>: Function list.extend was called with the wrong arguments [wrong-arg-types]']
Line 38: Unexpected errors ['File "tuples_unpacked.py", line 38, in <module>: Invalid type annotation \\'<instance of tuple>\\' [invalid-annotation]', 'File "tuples_unpacked.py", line 38, in <module>: Function list.extend was called with the wrong arguments [wrong-arg-types]']
Line 39: Unexpected errors ['File "tuples_unpacked.py", line 39, in <module>: Invalid type annotation \\'<instance of tuple>\\' [invalid-annotation]']
Line 46: Unexpected errors ['File "tuples_unpacked.py", line 46, in <module>: Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count]']
Line 49: Unexpected errors ['File "tuples_unpacked.py", line 49, in <module>: Invalid type annotation \\'<instance of Tuple[nothing, ...]>\\' [invalid-annotation]']
Line 50: Unexpected errors ['File "tuples_unpacked.py", line 50, in func3: Invalid type annotation \\'tuple[*tuple[str], *Ts]\\' [invalid-annotation]']
"""
7 changes: 4 additions & 3 deletions conformance/tests/tuples_unpacked.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ def func2(x: tuple[int, *tuple[bool, ...], str]):
assert_type(x, tuple[int, *tuple[bool, ...], str])


# > As with TypeVarTuples, only one unpacking may appear in a tuple:
# > For example, tuple[int, *tuple[str]] is equivalent to tuple[int, str].

bad1: tuple[*tuple[int], *tuple[int]] # E
bad2: tuple[*tuple[int, ...], *tuple[int]] # E
u1: tuple[*tuple[int], *tuple[int]] = (int(1), int(1)) # OK
assert_type(u1, tuple[int, int])
u2: tuple[*tuple[int, ...], *tuple[int]] # OK


# > Only one unbounded tuple can be used within another tuple:
Expand Down