diff --git a/conformance/results/mypy/generics_defaults.toml b/conformance/results/mypy/generics_defaults.toml index 7c73b68e..bc4145c4 100644 --- a/conformance/results/mypy/generics_defaults.toml +++ b/conformance/results/mypy/generics_defaults.toml @@ -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]'] @@ -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]'] """ diff --git a/conformance/results/pyre/generics_defaults.toml b/conformance/results/pyre/generics_defaults.toml index 2db9965f..b3985318 100644 --- a/conformance/results/pyre/generics_defaults.toml +++ b/conformance/results/pyre/generics_defaults.toml @@ -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.'] @@ -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`.'] """ diff --git a/conformance/results/pyright/generics_defaults.toml b/conformance/results/pyright/generics_defaults.toml index fc55cd20..16b3cc3c 100644 --- a/conformance/results/pyright/generics_defaults.toml +++ b/conformance/results/pyright/generics_defaults.toml @@ -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 = """ diff --git a/conformance/results/pytype/generics_defaults.toml b/conformance/results/pytype/generics_defaults.toml index 3f832185..68c0f844 100644 --- a/conformance/results/pytype/generics_defaults.toml +++ b/conformance/results/pytype/generics_defaults.toml @@ -185,97 +185,102 @@ generics_defaults.py:96:46: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <mod assert_type(Class_TypeVarTuple[int, bool](), Class_TypeVarTuple[int, bool]) \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m -generics_defaults.py:103:7: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: wrong arguments [invalid-typevar] +generics_defaults.py:99:61: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: Invalid type annotation '<instance of TypeVarTuple>' [invalid-annotation] + +AnotherDefaultTs = TypeVarTuple("AnotherDefaultTs", default=Unpack[DefaultTs]) + \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m + +generics_defaults.py:106:7: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: wrong arguments [invalid-typevar] Ok1 = TypeVar("Ok1", bound=float, default=int) # OK \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m -generics_defaults.py:104:12: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: wrong arguments [invalid-typevar] +generics_defaults.py:107:12: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: wrong arguments [invalid-typevar] Invalid1 = TypeVar("Invalid1", bound=str, default=int) # E: the bound and default are incompatible \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m -generics_defaults.py:110:7: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: wrong arguments [invalid-typevar] +generics_defaults.py:113:7: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: wrong arguments [invalid-typevar] Ok2 = TypeVar("Ok2", float, str, default=float) # OK \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m -generics_defaults.py:111:12: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: wrong arguments [invalid-typevar] +generics_defaults.py:114:12: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: wrong arguments [invalid-typevar] Invalid2 = TypeVar("Invalid2", float, str, default=int) # E: expected one of float or str got int \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m -generics_defaults.py:121:6: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: wrong arguments [invalid-typevar] +generics_defaults.py:124:6: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: wrong arguments [invalid-typevar] T4 = TypeVar("T4", default=int) \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m -generics_defaults.py:127:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: Any [assert-type] +generics_defaults.py:130:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: Any [assert-type] assert_type(func1(0), int) \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m -generics_defaults.py:135:6: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: wrong arguments [invalid-typevar] +generics_defaults.py:138:6: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: wrong arguments [invalid-typevar] T5 = TypeVar("T5", default=bool) \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m -generics_defaults.py:138:12: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: Invalid type annotation 'Generic' [invalid-annotation] +generics_defaults.py:141:12: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: Invalid type annotation 'Generic' [invalid-annotation] class Foo5(Generic[*Ts, T5]): ... # E \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m -generics_defaults.py:145:5: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: wrong arguments [invalid-typevar] +generics_defaults.py:148:5: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: wrong arguments [invalid-typevar] P = ParamSpec("P", default=[float, bool]) \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m -generics_defaults.py:148:12: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: Invalid type annotation 'Generic' [invalid-annotation] +generics_defaults.py:151:12: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: Invalid type annotation 'Generic' [invalid-annotation] class Foo6(Generic[*Ts, P]): ... # OK \u001b[1m\u001b[31m~~~~~~~~~~~~~~~\u001b[39m\u001b[0m -generics_defaults.py:151:13: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: class Foo6 is not indexable [not-indexable] +generics_defaults.py:154:13: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: class Foo6 is not indexable [not-indexable] assert_type(Foo6[int, str], type[Foo6[int, str, [float, bool]]]) \u001b[1m\u001b[31m~~~~~~~~~~~~~~\u001b[39m\u001b[0m -generics_defaults.py:151:34: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: class Foo6 is not indexable [not-indexable] +generics_defaults.py:154:34: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: class Foo6 is not indexable [not-indexable] assert_type(Foo6[int, str], type[Foo6[int, str, [float, bool]]]) \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m -generics_defaults.py:152:13: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: class Foo6 is not indexable [not-indexable] +generics_defaults.py:155:13: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: class Foo6 is not indexable [not-indexable] assert_type(Foo6[int, str, [bytes]], type[Foo6[int, str, [bytes]]]) \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m -generics_defaults.py:152:43: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: class Foo6 is not indexable [not-indexable] +generics_defaults.py:155:43: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: class Foo6 is not indexable [not-indexable] assert_type(Foo6[int, str, [bytes]], type[Foo6[int, str, [bytes]]]) \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m -generics_defaults.py:159:12: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: Invalid type annotation 'Generic' [invalid-annotation] +generics_defaults.py:162:12: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: Invalid type annotation 'Generic' [invalid-annotation] class Foo7(Generic[DefaultIntT]): \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m -generics_defaults.py:166:34: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: class Foo7 is not indexable [not-indexable] +generics_defaults.py:169:34: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: class Foo7 is not indexable [not-indexable] assert_type(Foo7.meth, Callable[[Foo7[int]], Foo7[int]]) \u001b[1m\u001b[31m~~~~~~~~~\u001b[39m\u001b[0m -generics_defaults.py:166:46: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: class Foo7 is not indexable [not-indexable] +generics_defaults.py:169:46: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: class Foo7 is not indexable [not-indexable] assert_type(Foo7.meth, Callable[[Foo7[int]], Foo7[int]]) \u001b[1m\u001b[31m~~~~~~~~~\u001b[39m\u001b[0m -generics_defaults.py:166:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: Callable[[Any], Self] [assert-type] +generics_defaults.py:169:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: Callable[[Any], Self] [assert-type] assert_type(Foo7.meth, Callable[[Foo7[int]], Foo7[int]]) \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m -generics_defaults.py:167:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: Any [assert-type] +generics_defaults.py:170:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: Any [assert-type] assert_type(Foo7.attr, int) \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m @@ -314,16 +319,17 @@ Line 91: Unexpected errors ["generics_defaults.py:91:26: \\x1b[1m\\x1b[31merror\ Line 94: Unexpected errors ['generics_defaults.py:94:38: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: class Class_TypeVarTuple is not indexable [not-indexable]'] Line 95: Unexpected errors ['generics_defaults.py:95:35: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: class Class_TypeVarTuple is not indexable [not-indexable]'] Line 96: Unexpected errors ['generics_defaults.py:96:13: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: class Class_TypeVarTuple is not indexable [not-indexable]', 'generics_defaults.py:96:46: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: class Class_TypeVarTuple is not indexable [not-indexable]'] -Line 103: Unexpected errors ['generics_defaults.py:103:7: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: wrong arguments [invalid-typevar]'] -Line 110: Unexpected errors ['generics_defaults.py:110:7: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: wrong arguments [invalid-typevar]'] -Line 121: Unexpected errors ['generics_defaults.py:121:6: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: wrong arguments [invalid-typevar]'] -Line 127: Unexpected errors ['generics_defaults.py:127:1: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: Any [assert-type]'] -Line 135: Unexpected errors ['generics_defaults.py:135:6: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: wrong arguments [invalid-typevar]'] -Line 145: Unexpected errors ['generics_defaults.py:145:5: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: wrong arguments [invalid-typevar]'] -Line 148: Unexpected errors ["generics_defaults.py:148:12: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: Invalid type annotation 'Generic' [invalid-annotation]"] -Line 151: Unexpected errors ['generics_defaults.py:151:13: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: class Foo6 is not indexable [not-indexable]', 'generics_defaults.py:151:34: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: class Foo6 is not indexable [not-indexable]'] -Line 152: Unexpected errors ['generics_defaults.py:152:13: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: class Foo6 is not indexable [not-indexable]', 'generics_defaults.py:152:43: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: class Foo6 is not indexable [not-indexable]'] -Line 159: Unexpected errors ["generics_defaults.py:159:12: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: Invalid type annotation 'Generic' [invalid-annotation]"] -Line 166: Unexpected errors ['generics_defaults.py:166:34: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: class Foo7 is not indexable [not-indexable]', 'generics_defaults.py:166:46: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: class Foo7 is not indexable [not-indexable]', 'generics_defaults.py:166:1: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: Callable[[Any], Self] [assert-type]'] -Line 167: Unexpected errors ['generics_defaults.py:167:1: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: Any [assert-type]'] +Line 99: Unexpected errors ["generics_defaults.py:99:61: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: Invalid type annotation '<instance of TypeVarTuple>' [invalid-annotation]"] +Line 106: Unexpected errors ['generics_defaults.py:106:7: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: wrong arguments [invalid-typevar]'] +Line 113: Unexpected errors ['generics_defaults.py:113:7: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: wrong arguments [invalid-typevar]'] +Line 124: Unexpected errors ['generics_defaults.py:124:6: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: wrong arguments [invalid-typevar]'] +Line 130: Unexpected errors ['generics_defaults.py:130:1: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: Any [assert-type]'] +Line 138: Unexpected errors ['generics_defaults.py:138:6: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: wrong arguments [invalid-typevar]'] +Line 148: Unexpected errors ['generics_defaults.py:148:5: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: wrong arguments [invalid-typevar]'] +Line 151: Unexpected errors ["generics_defaults.py:151:12: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: Invalid type annotation 'Generic' [invalid-annotation]"] +Line 154: Unexpected errors ['generics_defaults.py:154:13: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: class Foo6 is not indexable [not-indexable]', 'generics_defaults.py:154:34: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: class Foo6 is not indexable [not-indexable]'] +Line 155: Unexpected errors ['generics_defaults.py:155:13: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: class Foo6 is not indexable [not-indexable]', 'generics_defaults.py:155:43: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: class Foo6 is not indexable [not-indexable]'] +Line 162: Unexpected errors ["generics_defaults.py:162:12: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: Invalid type annotation 'Generic' [invalid-annotation]"] +Line 169: Unexpected errors ['generics_defaults.py:169:34: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: class Foo7 is not indexable [not-indexable]', 'generics_defaults.py:169:46: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: class Foo7 is not indexable [not-indexable]', 'generics_defaults.py:169:1: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: Callable[[Any], Self] [assert-type]'] +Line 170: Unexpected errors ['generics_defaults.py:170:1: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: Any [assert-type]'] """ diff --git a/conformance/results/pytype/specialtypes_never.toml b/conformance/results/pytype/specialtypes_never.toml index 7a231858..be27a72a 100644 --- a/conformance/results/pytype/specialtypes_never.toml +++ b/conformance/results/pytype/specialtypes_never.toml @@ -8,11 +8,10 @@ specialtypes_never.py:11:8: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <mod T_co = TypeVar("T_co", covariant=True) \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m -specialtypes_never.py:21:8: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in func1: bad return type [bad-return-type] +specialtypes_never.py:21:5: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in func1: bad return type [bad-return-type] - sys.exit(1) \u001b[1m\u001b[31m~~~~~~~~~~~\u001b[39m\u001b[0m sys.exit(1) -\u001b[1m\u001b[31m~~~~~~~~~~~~~\u001b[39m\u001b[0m + \u001b[1m\u001b[31m~~~~~~~~~~~~~~~\u001b[39m\u001b[0m specialtypes_never.py:68:5: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in func6: Type annotation for v1 does not match type of assignment [annotation-type-mismatch] @@ -40,7 +39,7 @@ errors_diff = """ Line 19: Expected 1 errors Line 105: Expected 1 errors Line 11: Unexpected errors ['specialtypes_never.py:11:8: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: argument "covariant" to TypeVar not supported yet [not-supported-yet]'] -Line 21: Unexpected errors ['specialtypes_never.py:21:8: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in func1: bad return type [bad-return-type]'] +Line 21: Unexpected errors ['specialtypes_never.py:21:5: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in func1: bad return type [bad-return-type]'] Line 68: Unexpected errors ['specialtypes_never.py:68:5: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in func6: Type annotation for v1 does not match type of assignment [annotation-type-mismatch]'] Line 69: Unexpected errors ['specialtypes_never.py:69:5: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in func6: Type annotation for v2 does not match type of assignment [annotation-type-mismatch]'] Line 70: Unexpected errors ['specialtypes_never.py:70:5: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in func6: Type annotation for v3 does not match type of assignment [annotation-type-mismatch]'] diff --git a/conformance/tests/generics_defaults.py b/conformance/tests/generics_defaults.py index af347b10..7ac1f8ed 100644 --- a/conformance/tests/generics_defaults.py +++ b/conformance/tests/generics_defaults.py @@ -82,8 +82,8 @@ class Class_ParamSpec(Generic[DefaultP]): ... # > ``TypeVarTuple`` defaults are defined using the same syntax as -# > ``TypeVar`` \ s but use an unpacked tuple of types instead of a single type -# > or another in-scope ``TypeVarTuple`` (see `Scoping Rules`_). +# > ``TypeVar`` \ s, but instead of a single type, they use an unpacked tuple +# > of types or an unpacked, in-scope ``TypeVarTuple`` (see `Scoping Rules`_). DefaultTs = TypeVarTuple("DefaultTs", default=Unpack[tuple[str, int]]) @@ -96,6 +96,9 @@ class Class_TypeVarTuple(Generic[*DefaultTs]): ... assert_type(Class_TypeVarTuple[int, bool](), Class_TypeVarTuple[int, bool]) +AnotherDefaultTs = TypeVarTuple("AnotherDefaultTs", default=Unpack[DefaultTs]) + + # > If both ``bound`` and ``default`` are passed, ``default`` must be a # > subtype of ``bound``. If not, the type checker should generate an # > error. diff --git a/docs/spec/generics.rst b/docs/spec/generics.rst index 65eeea94..942abb66 100644 --- a/docs/spec/generics.rst +++ b/docs/spec/generics.rst @@ -1919,8 +1919,8 @@ literal "``...``" or another in-scope ``ParamSpec`` (see `Scoping Rules`_). ^^^^^^^^^^^^^^^^^^^^^^^^^ ``TypeVarTuple`` defaults are defined using the same syntax as -``TypeVar`` \ s but use an unpacked tuple of types instead of a single type -or another in-scope ``TypeVarTuple`` (see `Scoping Rules`_). +``TypeVar`` \ s, but instead of a single type, they use an unpacked tuple of +types or an unpacked, in-scope ``TypeVarTuple`` (see `Scoping Rules`_). ::