diff --git a/conformance/results/mypy/aliases_type_statement.toml b/conformance/results/mypy/aliases_type_statement.toml index d33d02759..b69d735a7 100644 --- a/conformance/results/mypy/aliases_type_statement.toml +++ b/conformance/results/mypy/aliases_type_statement.toml @@ -1,7 +1,4 @@ -conformant = "Partial" -notes = """ -Does not reject type alias defined in function scope. -""" +conformant = "Pass" output = """ aliases_type_statement.py:17: error: "TypeAliasType" has no attribute "bit_count" [attr-defined] aliases_type_statement.py:19: error: "TypeAliasType" not callable [operator] @@ -24,18 +21,16 @@ aliases_type_statement.py:46: error: Invalid type: try using Literal[True] inste aliases_type_statement.py:47: error: Invalid type: try using Literal[1] instead? [valid-type] aliases_type_statement.py:48: error: Invalid type alias: expression is not a valid type [valid-type] aliases_type_statement.py:49: error: Invalid type alias: expression is not a valid type [valid-type] -aliases_type_statement.py:52: error: Name "BadTypeAlias14" already defined on line 51 [no-redef] -aliases_type_statement.py:62: error: All type parameters should be declared ("V" not declared) [valid-type] -aliases_type_statement.py:67: error: All type parameters should be declared ("T1" not declared) [valid-type] -aliases_type_statement.py:77: error: Type argument "str" of "RecursiveTypeAlias2" must be a subtype of "int" [type-var] -aliases_type_statement.py:79: error: Type argument "int" of "RecursiveTypeAlias2" must be a subtype of "str" [type-var] -aliases_type_statement.py:82: error: Cannot resolve name "RecursiveTypeAlias3" (possible cyclic definition) [misc] -aliases_type_statement.py:84: error: Invalid recursive alias: a union item of itself [misc] -aliases_type_statement.py:88: error: Cannot resolve name "RecursiveTypeAlias6" (possible cyclic definition) [misc] -aliases_type_statement.py:88: error: Cannot resolve name "RecursiveTypeAlias7" (possible cyclic definition) [misc] -aliases_type_statement.py:89: error: Cannot resolve name "RecursiveTypeAlias7" (possible cyclic definition) [misc] +aliases_type_statement.py:53: error: All type parameters should be declared ("V" not declared) [valid-type] +aliases_type_statement.py:58: error: All type parameters should be declared ("T1" not declared) [valid-type] +aliases_type_statement.py:68: error: Type argument "str" of "RecursiveTypeAlias2" must be a subtype of "int" [type-var] +aliases_type_statement.py:70: error: Type argument "int" of "RecursiveTypeAlias2" must be a subtype of "str" [type-var] +aliases_type_statement.py:73: error: Cannot resolve name "RecursiveTypeAlias3" (possible cyclic definition) [misc] +aliases_type_statement.py:75: error: Invalid recursive alias: a union item of itself [misc] +aliases_type_statement.py:79: error: Cannot resolve name "RecursiveTypeAlias6" (possible cyclic definition) [misc] +aliases_type_statement.py:79: error: Cannot resolve name "RecursiveTypeAlias7" (possible cyclic definition) [misc] +aliases_type_statement.py:80: error: Cannot resolve name "RecursiveTypeAlias7" (possible cyclic definition) [misc] """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 56: Expected 1 errors """ diff --git a/conformance/results/pyrefly/aliases_type_statement.toml b/conformance/results/pyrefly/aliases_type_statement.toml index 01603ba9d..2feb71761 100644 --- a/conformance/results/pyrefly/aliases_type_statement.toml +++ b/conformance/results/pyrefly/aliases_type_statement.toml @@ -23,14 +23,12 @@ ERROR aliases_type_statement.py:46:23-27: Bool literal cannot be used in annotat ERROR aliases_type_statement.py:47:23-24: Number literal cannot be used in annotations [invalid-annotation] ERROR aliases_type_statement.py:48:23-34: Boolean operation cannot be used in annotations [invalid-annotation] ERROR aliases_type_statement.py:49:23-33: F-string cannot be used in annotations [invalid-annotation] -ERROR aliases_type_statement.py:52:6-20: Cannot redefine existing type alias `BadTypeAlias14` [redefinition] -ERROR aliases_type_statement.py:56:5-30: `type` statement is not allowed in this context [invalid-syntax] -ERROR aliases_type_statement.py:62:15-25: Type parameters used in `TA1` but not declared [invalid-type-var] -ERROR aliases_type_statement.py:67:12-20: Type parameters used in `TA2` but not declared [invalid-type-var] -ERROR aliases_type_statement.py:77:7-41: `str` is not assignable to upper bound `int` of type variable `S` [bad-specialization] -ERROR aliases_type_statement.py:79:7-41: `int` is not assignable to upper bound `str` of type variable `T` [bad-specialization] -ERROR aliases_type_statement.py:82:28-47: Found cyclic self-reference in `RecursiveTypeAlias3` [invalid-type-alias] -ERROR aliases_type_statement.py:84:31-59: Found cyclic self-reference in `RecursiveTypeAlias4` [invalid-type-alias] -ERROR aliases_type_statement.py:88:28-47: Found cyclic self-reference in `RecursiveTypeAlias6` [invalid-type-alias] -ERROR aliases_type_statement.py:89:28-47: Found cyclic self-reference in `RecursiveTypeAlias7` [invalid-type-alias] +ERROR aliases_type_statement.py:53:15-25: Type parameters used in `TA1` but not declared [invalid-type-var] +ERROR aliases_type_statement.py:58:12-20: Type parameters used in `TA2` but not declared [invalid-type-var] +ERROR aliases_type_statement.py:68:7-41: `str` is not assignable to upper bound `int` of type variable `S` [bad-specialization] +ERROR aliases_type_statement.py:70:7-41: `int` is not assignable to upper bound `str` of type variable `T` [bad-specialization] +ERROR aliases_type_statement.py:73:28-47: Found cyclic self-reference in `RecursiveTypeAlias3` [invalid-type-alias] +ERROR aliases_type_statement.py:75:31-59: Found cyclic self-reference in `RecursiveTypeAlias4` [invalid-type-alias] +ERROR aliases_type_statement.py:79:28-47: Found cyclic self-reference in `RecursiveTypeAlias6` [invalid-type-alias] +ERROR aliases_type_statement.py:80:28-47: Found cyclic self-reference in `RecursiveTypeAlias7` [invalid-type-alias] """ diff --git a/conformance/results/pyright/aliases_type_statement.toml b/conformance/results/pyright/aliases_type_statement.toml index 34269c479..407dbd082 100644 --- a/conformance/results/pyright/aliases_type_statement.toml +++ b/conformance/results/pyright/aliases_type_statement.toml @@ -36,19 +36,17 @@ aliases_type_statement.py:46:23 - error: Expected class but received "Literal[Tr aliases_type_statement.py:47:23 - error: Expected class but received "Literal[1]" (reportGeneralTypeIssues) aliases_type_statement.py:48:23 - error: Binary operator not allowed in type expression (reportInvalidTypeForm) aliases_type_statement.py:49:23 - error: Type expressions cannot use format string literals (f-strings) (reportGeneralTypeIssues) -aliases_type_statement.py:51:6 - error: Type alias declaration "BadTypeAlias14" is obscured by a declaration of the same name (reportRedeclaration) -aliases_type_statement.py:56:10 - error: A type statement can be used only within a module or class scope (reportGeneralTypeIssues) -aliases_type_statement.py:62:23 - error: Type parameter "V" is not included in the type parameter list for "TA1" (reportGeneralTypeIssues) -aliases_type_statement.py:67:17 - error: Type parameter "T1" is not included in the type parameter list for "TA2" (reportGeneralTypeIssues) -aliases_type_statement.py:77:7 - error: Could not specialize type "RecursiveTypeAlias2[S@RecursiveTypeAlias2, T@RecursiveTypeAlias2, P@RecursiveTypeAlias2]" +aliases_type_statement.py:53:23 - error: Type parameter "V" is not included in the type parameter list for "TA1" (reportGeneralTypeIssues) +aliases_type_statement.py:58:17 - error: Type parameter "T1" is not included in the type parameter list for "TA2" (reportGeneralTypeIssues) +aliases_type_statement.py:68:7 - error: Could not specialize type "RecursiveTypeAlias2[S@RecursiveTypeAlias2, T@RecursiveTypeAlias2, P@RecursiveTypeAlias2]"   Type "str" is not assignable to type "int"     "str" is not assignable to "int" (reportInvalidTypeForm) -aliases_type_statement.py:79:7 - error: Could not specialize type "RecursiveTypeAlias2[S@RecursiveTypeAlias2, T@RecursiveTypeAlias2, P@RecursiveTypeAlias2]" +aliases_type_statement.py:70:7 - error: Could not specialize type "RecursiveTypeAlias2[S@RecursiveTypeAlias2, T@RecursiveTypeAlias2, P@RecursiveTypeAlias2]"   Type "int" is not assignable to type "str"     "int" is not assignable to "str" (reportInvalidTypeForm) -aliases_type_statement.py:82:28 - error: Type alias "RecursiveTypeAlias3" cannot use itself in its definition (reportGeneralTypeIssues) -aliases_type_statement.py:84:31 - error: Type alias "RecursiveTypeAlias4" cannot use itself in its definition (reportGeneralTypeIssues) -aliases_type_statement.py:88:28 - error: Type alias "RecursiveTypeAlias6" cannot use itself in its definition (reportGeneralTypeIssues) +aliases_type_statement.py:73:28 - error: Type alias "RecursiveTypeAlias3" cannot use itself in its definition (reportGeneralTypeIssues) +aliases_type_statement.py:75:31 - error: Type alias "RecursiveTypeAlias4" cannot use itself in its definition (reportGeneralTypeIssues) +aliases_type_statement.py:79:28 - error: Type alias "RecursiveTypeAlias6" cannot use itself in its definition (reportGeneralTypeIssues) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/results.html b/conformance/results/results.html index 3ddb751cd..9f6daf178 100644 --- a/conformance/results/results.html +++ b/conformance/results/results.html @@ -555,11 +555,11 @@

Python Type System Conformance Test Results

Unsupported      aliases_type_statement -
Partial

Does not reject type alias defined in function scope.

Pass Pass Pass -
Partial

Does not reject use of the `type` statement inside functions.

Does not reject circular definitions of type aliases.

Does not reject redeclarations of type aliases.

Does not support `type` statements generic over `TypeVarTuple`s.

+Pass +
Partial

Does not reject circular definitions of type aliases.

Does not support `type` statements generic over `TypeVarTuple`s.

     aliases_typealiastype
Partial

Incorrectly rejects some recursive type aliases using TypeAliasType.

Incorrectly rejects the use of a class-scoped TypeVar in a TypeAliasType definition.

diff --git a/conformance/results/ty/aliases_type_statement.toml b/conformance/results/ty/aliases_type_statement.toml index e50de45f2..d1175af88 100644 --- a/conformance/results/ty/aliases_type_statement.toml +++ b/conformance/results/ty/aliases_type_statement.toml @@ -1,15 +1,11 @@ conformance_automated = "Fail" conformant = "Partial" notes = """ -Does not reject use of the `type` statement inside functions. Does not reject circular definitions of type aliases. -Does not reject redeclarations of type aliases. Does not support `type` statements generic over `TypeVarTuple`s. """ errors_diff = """ -Line 56: Expected 1 errors -Line 84: Expected 1 errors -Lines 51, 52: Expected error (tag 'TA14') +Line 75: Expected 1 errors Line 10: Unexpected errors ['aliases_type_statement.py:10:52: error[invalid-type-arguments] Too many type arguments: expected 2, got 3', 'aliases_type_statement.py:10:52: error[invalid-type-form] `...` is not allowed in this context in a type alias value'] """ output = """ @@ -33,11 +29,11 @@ aliases_type_statement.py:46:23: error[invalid-type-form] Boolean literals are n aliases_type_statement.py:47:23: error[invalid-type-form] Int literals are not allowed in this context in a type alias value: Did you mean `typing.Literal[1]`? aliases_type_statement.py:48:23: error[invalid-type-form] Boolean operations are not allowed in type alias values aliases_type_statement.py:49:23: error[invalid-type-form] F-strings are not allowed in type alias values -aliases_type_statement.py:62:23: error[unbound-type-variable] Type variable `V` is not bound to any outer generic context -aliases_type_statement.py:67:17: error[unbound-type-variable] Type variable `T1` is not bound to any outer generic context -aliases_type_statement.py:77:27: error[invalid-type-arguments] Type `str` is not assignable to upper bound `int` of type variable `S@RecursiveTypeAlias2` -aliases_type_statement.py:79:32: error[invalid-type-arguments] Type `int` is not assignable to upper bound `str` of type variable `T@RecursiveTypeAlias2` -aliases_type_statement.py:82:1: error[cyclic-type-alias-definition] Cyclic definition of `RecursiveTypeAlias3` -aliases_type_statement.py:88:1: error[cyclic-type-alias-definition] Cyclic definition of `RecursiveTypeAlias6` -aliases_type_statement.py:89:1: error[cyclic-type-alias-definition] Cyclic definition of `RecursiveTypeAlias7` +aliases_type_statement.py:53:23: error[unbound-type-variable] Type variable `V` is not bound to any outer generic context +aliases_type_statement.py:58:17: error[unbound-type-variable] Type variable `T1` is not bound to any outer generic context +aliases_type_statement.py:68:27: error[invalid-type-arguments] Type `str` is not assignable to upper bound `int` of type variable `S@RecursiveTypeAlias2` +aliases_type_statement.py:70:32: error[invalid-type-arguments] Type `int` is not assignable to upper bound `str` of type variable `T@RecursiveTypeAlias2` +aliases_type_statement.py:73:1: error[cyclic-type-alias-definition] Cyclic definition of `RecursiveTypeAlias3` +aliases_type_statement.py:79:1: error[cyclic-type-alias-definition] Cyclic definition of `RecursiveTypeAlias6` +aliases_type_statement.py:80:1: error[cyclic-type-alias-definition] Cyclic definition of `RecursiveTypeAlias7` """ diff --git a/conformance/results/zuban/aliases_type_statement.toml b/conformance/results/zuban/aliases_type_statement.toml index b82e24b75..96056df21 100644 --- a/conformance/results/zuban/aliases_type_statement.toml +++ b/conformance/results/zuban/aliases_type_statement.toml @@ -23,13 +23,11 @@ aliases_type_statement.py:46: error: Invalid type alias: expression is not a val aliases_type_statement.py:47: error: Invalid type: try using Literal[1] instead? [valid-type] aliases_type_statement.py:48: error: Invalid type alias: expression is not a valid type [valid-type] aliases_type_statement.py:49: error: Invalid type alias: expression is not a valid type [valid-type] -aliases_type_statement.py:52: error: Name "BadTypeAlias14" already defined on line 51 [no-redef] -aliases_type_statement.py:56: error: Type alias not allowed in function [misc] -aliases_type_statement.py:62: error: All type parameters should be declared ("V" not declared) [misc] -aliases_type_statement.py:67: error: All type parameters should be declared ("T1" not declared) [misc] -aliases_type_statement.py:77: error: Type argument "str" of "RecursiveTypeAlias2" must be a subtype of "int" [type-var] -aliases_type_statement.py:79: error: Type argument "int" of "RecursiveTypeAlias2" must be a subtype of "str" [type-var] -aliases_type_statement.py:82: error: Invalid recursive alias: a union item of itself [misc] -aliases_type_statement.py:84: error: Invalid recursive alias: a union item of itself [misc] -aliases_type_statement.py:88: error: Invalid recursive alias: a union item of itself [misc] +aliases_type_statement.py:53: error: All type parameters should be declared ("V" not declared) [misc] +aliases_type_statement.py:58: error: All type parameters should be declared ("T1" not declared) [misc] +aliases_type_statement.py:68: error: Type argument "str" of "RecursiveTypeAlias2" must be a subtype of "int" [type-var] +aliases_type_statement.py:70: error: Type argument "int" of "RecursiveTypeAlias2" must be a subtype of "str" [type-var] +aliases_type_statement.py:73: error: Invalid recursive alias: a union item of itself [misc] +aliases_type_statement.py:75: error: Invalid recursive alias: a union item of itself [misc] +aliases_type_statement.py:79: error: Invalid recursive alias: a union item of itself [misc] """ diff --git a/conformance/tests/aliases_type_statement.py b/conformance/tests/aliases_type_statement.py index c373b53ef..2cca5bfce 100644 --- a/conformance/tests/aliases_type_statement.py +++ b/conformance/tests/aliases_type_statement.py @@ -48,15 +48,6 @@ def func2(x: object): type BadTypeAlias12 = list or set # E type BadTypeAlias13 = f"{'int'}" # E -type BadTypeAlias14 = int # E[TA14]: redeclared -type BadTypeAlias14 = int # E[TA14]: redeclared - - -def func3(): - type BadTypeAlias15 = int # E: alias not allowed in function - - - V = TypeVar("V") type TA1[K] = dict[K, V] # E: combines old and new TypeVars