Skip to content

Clarify that a TypeVarTuple default always has to be unpacked #1971

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
28 changes: 14 additions & 14 deletions conformance/results/mypy/generics_defaults.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ generics_defaults.py:55: error: Expression is of type "type[AllTheDefaults[int,
generics_defaults.py:59: error: Expression is of type "type[AllTheDefaults[int, complex, str, int, DefaultBoolT]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]
generics_defaults.py:79: error: Expression is of type "type[Class_ParamSpec[DefaultP]]", not "type[Class_ParamSpec[[str, int]]]" [assert-type]
generics_defaults.py:94: error: Expression is of type "type[Class_TypeVarTuple[*DefaultTs]]", not "type[Class_TypeVarTuple[str, int]]" [assert-type]
generics_defaults.py:104: error: TypeVar default must be a subtype of the bound type [misc]
generics_defaults.py:111: error: TypeVar default must be one of the constraint types [misc]
generics_defaults.py:151: error: Expression is of type "type[Foo6[*tuple[Any, ...], Any]]", not "type[Foo6[int, str, [float, bool]]]" [assert-type]
generics_defaults.py:151: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [misc]
generics_defaults.py:152: error: Expression is of type "type[Foo6[*tuple[Any, ...], Any]]", not "type[Foo6[int, str, [bytes]]]" [assert-type]
generics_defaults.py:152: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [misc]
generics_defaults.py:166: error: Expression is of type "Callable[[Self], Self]", not "Callable[[Foo7[int]], Foo7[int]]" [assert-type]
generics_defaults.py:167: error: Expression is of type "Any", not "int" [assert-type]
generics_defaults.py:167: error: Access to generic instance variables via class is ambiguous [misc]
generics_defaults.py:107: error: TypeVar default must be a subtype of the bound type [misc]
generics_defaults.py:114: error: TypeVar default must be one of the constraint types [misc]
generics_defaults.py:154: error: Expression is of type "type[Foo6[*tuple[Any, ...], Any]]", not "type[Foo6[int, str, [float, bool]]]" [assert-type]
generics_defaults.py:154: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [misc]
generics_defaults.py:155: error: Expression is of type "type[Foo6[*tuple[Any, ...], Any]]", not "type[Foo6[int, str, [bytes]]]" [assert-type]
generics_defaults.py:155: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [misc]
generics_defaults.py:169: error: Expression is of type "Callable[[Self], Self]", not "Callable[[Foo7[int]], Foo7[int]]" [assert-type]
generics_defaults.py:170: error: Expression is of type "Any", not "int" [assert-type]
generics_defaults.py:170: error: Access to generic instance variables via class is ambiguous [misc]
"""
conformance_automated = "Fail"
errors_diff = """
Line 138: Expected 1 errors
Line 141: Expected 1 errors
Line 30: Unexpected errors ['generics_defaults.py:30: error: Expression is of type "type[NoNonDefaults[DefaultStrT, DefaultIntT]]", not "type[NoNonDefaults[str, int]]" [assert-type]']
Line 31: Unexpected errors ['generics_defaults.py:31: error: Expression is of type "type[NoNonDefaults[str, DefaultIntT]]", not "type[NoNonDefaults[str, int]]" [assert-type]']
Line 38: Unexpected errors ['generics_defaults.py:38: error: Expression is of type "type[OneDefault[float, DefaultBoolT]]", not "type[OneDefault[float, bool]]" [assert-type]']
Expand All @@ -35,8 +35,8 @@ Line 55: Unexpected errors ['generics_defaults.py:55: error: Expression is of ty
Line 59: Unexpected errors ['generics_defaults.py:59: error: Expression is of type "type[AllTheDefaults[int, complex, str, int, DefaultBoolT]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]']
Line 79: Unexpected errors ['generics_defaults.py:79: error: Expression is of type "type[Class_ParamSpec[DefaultP]]", not "type[Class_ParamSpec[[str, int]]]" [assert-type]']
Line 94: Unexpected errors ['generics_defaults.py:94: error: Expression is of type "type[Class_TypeVarTuple[*DefaultTs]]", not "type[Class_TypeVarTuple[str, int]]" [assert-type]']
Line 151: Unexpected errors ['generics_defaults.py:151: error: Expression is of type "type[Foo6[*tuple[Any, ...], Any]]", not "type[Foo6[int, str, [float, bool]]]" [assert-type]', 'generics_defaults.py:151: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [misc]']
Line 152: Unexpected errors ['generics_defaults.py:152: error: Expression is of type "type[Foo6[*tuple[Any, ...], Any]]", not "type[Foo6[int, str, [bytes]]]" [assert-type]', 'generics_defaults.py:152: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [misc]']
Line 166: Unexpected errors ['generics_defaults.py:166: error: Expression is of type "Callable[[Self], Self]", not "Callable[[Foo7[int]], Foo7[int]]" [assert-type]']
Line 167: Unexpected errors ['generics_defaults.py:167: error: Expression is of type "Any", not "int" [assert-type]', 'generics_defaults.py:167: error: Access to generic instance variables via class is ambiguous [misc]']
Line 154: Unexpected errors ['generics_defaults.py:154: error: Expression is of type "type[Foo6[*tuple[Any, ...], Any]]", not "type[Foo6[int, str, [float, bool]]]" [assert-type]', 'generics_defaults.py:154: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [misc]']
Line 155: Unexpected errors ['generics_defaults.py:155: error: Expression is of type "type[Foo6[*tuple[Any, ...], Any]]", not "type[Foo6[int, str, [bytes]]]" [assert-type]', 'generics_defaults.py:155: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [misc]']
Line 169: Unexpected errors ['generics_defaults.py:169: error: Expression is of type "Callable[[Self], Self]", not "Callable[[Foo7[int]], Foo7[int]]" [assert-type]']
Line 170: Unexpected errors ['generics_defaults.py:170: error: Expression is of type "Any", not "int" [assert-type]', 'generics_defaults.py:170: error: Access to generic instance variables via class is ambiguous [misc]']
"""
2 changes: 1 addition & 1 deletion conformance/results/mypy/version.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "mypy 1.15.0"
test_duration = 2.1
test_duration = 3.8
48 changes: 25 additions & 23 deletions conformance/results/pyre/generics_defaults.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,27 @@ generics_defaults.py:95:34 Invalid type parameters [24]: Non-generic type `Class
generics_defaults.py:96:0 Assert type [70]: Expected `Class_TypeVarTuple[]` but got `typing.Any`.
generics_defaults.py:96:12 Undefined attribute [16]: `Class_TypeVarTuple` has no attribute `__getitem__`.
generics_defaults.py:96:45 Invalid type parameters [24]: Non-generic type `Class_TypeVarTuple` cannot take parameters.
generics_defaults.py:124:13 Undefined or invalid type [11]: Annotation `T4` is not defined as a type.
generics_defaults.py:127:0 Assert type [70]: Expected `int` but got `unknown`.
generics_defaults.py:138:11 Invalid type variable [34]: The current class isn't generic with respect to the type variable `Ts`.
generics_defaults.py:138:11 Undefined or invalid type [11]: Annotation `T5` is not defined as a type.
generics_defaults.py:148:11 Invalid type variable [34]: The current class isn't generic with respect to the type variable `Ts`.
generics_defaults.py:148:11 Undefined or invalid type [11]: Annotation `P` is not defined as a type.
generics_defaults.py:151:0 Assert type [70]: Expected `Type[Foo6[]]` but got `typing.Any`.
generics_defaults.py:151:12 Undefined attribute [16]: `Foo6` has no attribute `__getitem__`.
generics_defaults.py:151:28 Invalid type parameters [24]: Non-generic type `Foo6` cannot take parameters.
generics_defaults.py:152:0 Assert type [70]: Expected `Type[Foo6[]]` but got `typing.Any`.
generics_defaults.py:152:37 Invalid type parameters [24]: Non-generic type `Foo6` cannot take parameters.
generics_defaults.py:166:0 Assert type [70]: Expected `typing.Callable[[Foo7[]], Foo7[]]` but got `typing.Callable(Foo7.meth)[[Variable[_Self_generics_defaults_Foo7__ (bound to Foo7)]], Variable[_Self_generics_defaults_Foo7__ (bound to Foo7)]]`.
generics_defaults.py:166:23 Invalid type parameters [24]: Non-generic type `Foo7` cannot take parameters.
generics_defaults.py:167:0 Assert type [70]: Expected `int` but got `unknown`.
generics_defaults.py:99:67 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T]]` but got `TypeVarTuple`.
generics_defaults.py:127:13 Undefined or invalid type [11]: Annotation `T4` is not defined as a type.
generics_defaults.py:130:0 Assert type [70]: Expected `int` but got `unknown`.
generics_defaults.py:141:11 Invalid type variable [34]: The current class isn't generic with respect to the type variable `Ts`.
generics_defaults.py:141:11 Undefined or invalid type [11]: Annotation `T5` is not defined as a type.
generics_defaults.py:151:11 Invalid type variable [34]: The current class isn't generic with respect to the type variable `Ts`.
generics_defaults.py:151:11 Undefined or invalid type [11]: Annotation `P` is not defined as a type.
generics_defaults.py:154:0 Assert type [70]: Expected `Type[Foo6[]]` but got `typing.Any`.
generics_defaults.py:154:12 Undefined attribute [16]: `Foo6` has no attribute `__getitem__`.
generics_defaults.py:154:28 Invalid type parameters [24]: Non-generic type `Foo6` cannot take parameters.
generics_defaults.py:155:0 Assert type [70]: Expected `Type[Foo6[]]` but got `typing.Any`.
generics_defaults.py:155:37 Invalid type parameters [24]: Non-generic type `Foo6` cannot take parameters.
generics_defaults.py:169:0 Assert type [70]: Expected `typing.Callable[[Foo7[]], Foo7[]]` but got `typing.Callable(Foo7.meth)[[Variable[_Self_generics_defaults_Foo7__ (bound to Foo7)]], Variable[_Self_generics_defaults_Foo7__ (bound to Foo7)]]`.
generics_defaults.py:169:23 Invalid type parameters [24]: Non-generic type `Foo7` cannot take parameters.
generics_defaults.py:170:0 Assert type [70]: Expected `int` but got `unknown`.
"""
conformance_automated = "Fail"
errors_diff = """
Line 50: Expected 1 errors
Line 104: Expected 1 errors
Line 111: Expected 1 errors
Line 107: Expected 1 errors
Line 114: Expected 1 errors
Line 27: Unexpected errors ['generics_defaults.py:27:20 Undefined or invalid type [11]: Annotation `DefaultIntT` is not defined as a type.']
Line 30: Unexpected errors ['generics_defaults.py:30:0 Assert type [70]: Expected `Type[NoNonDefaults[]]` but got `Type[NoNonDefaults]`.', 'generics_defaults.py:30:27 Invalid type parameters [24]: Non-generic type `NoNonDefaults` cannot take parameters.']
Line 31: Unexpected errors ['generics_defaults.py:31:0 Assert type [70]: Expected `Type[NoNonDefaults[]]` but got `typing.Any`.', 'generics_defaults.py:31:12 Undefined attribute [16]: `NoNonDefaults` has no attribute `__getitem__`.', 'generics_defaults.py:31:32 Invalid type parameters [24]: Non-generic type `NoNonDefaults` cannot take parameters.']
Expand Down Expand Up @@ -97,11 +98,12 @@ Line 91: Unexpected errors ['generics_defaults.py:91:25 Undefined or invalid typ
Line 94: Unexpected errors ['generics_defaults.py:94:0 Assert type [70]: Expected `Type[Class_TypeVarTuple[]]` but got `Type[Class_TypeVarTuple]`.', 'generics_defaults.py:94:32 Invalid type parameters [24]: Non-generic type `Class_TypeVarTuple` cannot take parameters.']
Line 95: Unexpected errors ['generics_defaults.py:95:0 Assert type [70]: Expected `Class_TypeVarTuple[]` but got `Class_TypeVarTuple`.', 'generics_defaults.py:95:34 Invalid type parameters [24]: Non-generic type `Class_TypeVarTuple` cannot take parameters.']
Line 96: Unexpected errors ['generics_defaults.py:96:0 Assert type [70]: Expected `Class_TypeVarTuple[]` but got `typing.Any`.', 'generics_defaults.py:96:12 Undefined attribute [16]: `Class_TypeVarTuple` has no attribute `__getitem__`.', 'generics_defaults.py:96:45 Invalid type parameters [24]: Non-generic type `Class_TypeVarTuple` cannot take parameters.']
Line 124: Unexpected errors ['generics_defaults.py:124:13 Undefined or invalid type [11]: Annotation `T4` is not defined as a type.']
Line 127: Unexpected errors ['generics_defaults.py:127:0 Assert type [70]: Expected `int` but got `unknown`.']
Line 148: Unexpected errors ["generics_defaults.py:148:11 Invalid type variable [34]: The current class isn't generic with respect to the type variable `Ts`.", 'generics_defaults.py:148:11 Undefined or invalid type [11]: Annotation `P` is not defined as a type.']
Line 151: Unexpected errors ['generics_defaults.py:151:0 Assert type [70]: Expected `Type[Foo6[]]` but got `typing.Any`.', 'generics_defaults.py:151:12 Undefined attribute [16]: `Foo6` has no attribute `__getitem__`.', 'generics_defaults.py:151:28 Invalid type parameters [24]: Non-generic type `Foo6` cannot take parameters.']
Line 152: Unexpected errors ['generics_defaults.py:152:0 Assert type [70]: Expected `Type[Foo6[]]` but got `typing.Any`.', 'generics_defaults.py:152:37 Invalid type parameters [24]: Non-generic type `Foo6` cannot take parameters.']
Line 166: Unexpected errors ['generics_defaults.py:166:0 Assert type [70]: Expected `typing.Callable[[Foo7[]], Foo7[]]` but got `typing.Callable(Foo7.meth)[[Variable[_Self_generics_defaults_Foo7__ (bound to Foo7)]], Variable[_Self_generics_defaults_Foo7__ (bound to Foo7)]]`.', 'generics_defaults.py:166:23 Invalid type parameters [24]: Non-generic type `Foo7` cannot take parameters.']
Line 167: Unexpected errors ['generics_defaults.py:167:0 Assert type [70]: Expected `int` but got `unknown`.']
Line 99: Unexpected errors ['generics_defaults.py:99:67 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T]]` but got `TypeVarTuple`.']
Line 127: Unexpected errors ['generics_defaults.py:127:13 Undefined or invalid type [11]: Annotation `T4` is not defined as a type.']
Line 130: Unexpected errors ['generics_defaults.py:130:0 Assert type [70]: Expected `int` but got `unknown`.']
Line 151: Unexpected errors ["generics_defaults.py:151:11 Invalid type variable [34]: The current class isn't generic with respect to the type variable `Ts`.", 'generics_defaults.py:151:11 Undefined or invalid type [11]: Annotation `P` is not defined as a type.']
Line 154: Unexpected errors ['generics_defaults.py:154:0 Assert type [70]: Expected `Type[Foo6[]]` but got `typing.Any`.', 'generics_defaults.py:154:12 Undefined attribute [16]: `Foo6` has no attribute `__getitem__`.', 'generics_defaults.py:154:28 Invalid type parameters [24]: Non-generic type `Foo6` cannot take parameters.']
Line 155: Unexpected errors ['generics_defaults.py:155:0 Assert type [70]: Expected `Type[Foo6[]]` but got `typing.Any`.', 'generics_defaults.py:155:37 Invalid type parameters [24]: Non-generic type `Foo6` cannot take parameters.']
Line 169: Unexpected errors ['generics_defaults.py:169:0 Assert type [70]: Expected `typing.Callable[[Foo7[]], Foo7[]]` but got `typing.Callable(Foo7.meth)[[Variable[_Self_generics_defaults_Foo7__ (bound to Foo7)]], Variable[_Self_generics_defaults_Foo7__ (bound to Foo7)]]`.', 'generics_defaults.py:169:23 Invalid type parameters [24]: Non-generic type `Foo7` cannot take parameters.']
Line 170: Unexpected errors ['generics_defaults.py:170:0 Assert type [70]: Expected `int` but got `unknown`.']
"""
2 changes: 1 addition & 1 deletion conformance/results/pyre/version.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "pyre 0.9.23"
test_duration = 3.9
test_duration = 7.5
8 changes: 4 additions & 4 deletions conformance/results/pyright/generics_defaults.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ conformant = "Pass"
output = """
generics_defaults.py:24:7 - error: "T" cannot appear after "DefaultStrT" in type parameter list because it has no default type (reportGeneralTypeIssues)
generics_defaults.py:50:16 - error: Too few type arguments provided for "AllTheDefaults"; expected 2 but received 1 (reportInvalidTypeArguments)
generics_defaults.py:104:51 - error: TypeVar default type must be a subtype of the bound type (reportGeneralTypeIssues)
generics_defaults.py:111:52 - error: TypeVar default type must be one of the constrained types (reportGeneralTypeIssues)
generics_defaults.py:138:7 - error: TypeVar "T5" has a default value and cannot follow TypeVarTuple "Ts" (reportGeneralTypeIssues)
generics_defaults.py:167:18 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues)
generics_defaults.py:107:51 - error: TypeVar default type must be a subtype of the bound type (reportGeneralTypeIssues)
generics_defaults.py:114:52 - error: TypeVar default type must be one of the constrained types (reportGeneralTypeIssues)
generics_defaults.py:141:7 - error: TypeVar "T5" has a default value and cannot follow TypeVarTuple "Ts" (reportGeneralTypeIssues)
generics_defaults.py:170:18 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues)
"""
conformance_automated = "Pass"
errors_diff = """
Expand Down
4 changes: 2 additions & 2 deletions conformance/results/pyright/version.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "pyright 1.1.398"
test_duration = 2.3
version = "pyright 1.1.399"
test_duration = 3.9
Loading