Skip to content

Commit f86459c

Browse files
authored
Updated conformance results for mypy 1.12. (#1866)
* Fixes bugs that previously caused a crash when running generics_defaults and generics_syntax_declarations tests. * Fixes conformance issues in the following tests: aliases_type_statement, generics_paramspec_components, generics_syntax_declarations, generics_variance_inference, tuples_type_compat. * Adds support for functionality covered by tests: typeddicts_readonly, typeddicts_readonly_consistency, typeddicts_readonly_inheritance, typeddicts_readonly_kwargs, typeddicts_readonly_update. Fixed bugs in a couple of tests that were uncovered by mypy update. * The aliases_type_statement test assumed errors would be reported on a particular line. * The generics_syntax_declarations test assumed certain unspecified behaviors when evaluating the type of a type parameter. * The generics_variance_inference test was missing a return type annotation.
1 parent c5e52dd commit f86459c

33 files changed

+198
-285
lines changed

conformance/results/mypy/aliases_explicit.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ aliases_explicit.py:79: error: Invalid type alias: expression is not a valid typ
1212
aliases_explicit.py:80: error: Bracketed expression "[...]" is not valid as a type [valid-type]
1313
aliases_explicit.py:81: error: Invalid type alias: expression is not a valid type [valid-type]
1414
aliases_explicit.py:82: error: Invalid type alias: expression is not a valid type [valid-type]
15-
aliases_explicit.py:83: error: Invalid type alias: expression is not a valid type [valid-type]
15+
aliases_explicit.py:83: error: Inline TypedDict is experimental, must be enabled with --enable-incomplete-feature=InlineTypedDict [misc]
16+
aliases_explicit.py:83: error: Name "b" is not defined [name-defined]
1617
aliases_explicit.py:84: error: Invalid type alias: expression is not a valid type [valid-type]
1718
aliases_explicit.py:85: error: Invalid type alias: expression is not a valid type [valid-type]
1819
aliases_explicit.py:86: error: Invalid type alias: expression is not a valid type [valid-type]
Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
conformant = "Partial"
22
notes = """
3-
Does not reject use of TypeAliasType as base class.
4-
Does not reject redefinition of type alias defined with type statement.
53
Does not reject type alias defined in function scope.
6-
Does not reject type alias with circular definition.
74
"""
85
output = """
96
aliases_type_statement.py:17: error: "TypeAliasType" has no attribute "bit_count" [attr-defined]
107
aliases_type_statement.py:19: error: "TypeAliasType" not callable [operator]
118
aliases_type_statement.py:23: error: "TypeAliasType" has no attribute "other_attrib" [attr-defined]
9+
aliases_type_statement.py:26: error: Type alias defined using "type" statement not valid as base class [misc]
1210
aliases_type_statement.py:31: error: Parameterized generics cannot be used with class or instance checks [misc]
1311
aliases_type_statement.py:31: error: Argument 2 to "isinstance" has incompatible type "TypeAliasType"; expected "_ClassInfo" [arg-type]
1412
aliases_type_statement.py:37: error: Invalid type alias: expression is not a valid type [valid-type]
1513
aliases_type_statement.py:38: error: Bracketed expression "[...]" is not valid as a type [valid-type]
1614
aliases_type_statement.py:39: error: Invalid type alias: expression is not a valid type [valid-type]
1715
aliases_type_statement.py:40: error: Invalid type alias: expression is not a valid type [valid-type]
18-
aliases_type_statement.py:41: error: Invalid type alias: expression is not a valid type [valid-type]
16+
aliases_type_statement.py:41: error: Inline TypedDict is experimental, must be enabled with --enable-incomplete-feature=InlineTypedDict [misc]
17+
aliases_type_statement.py:41: error: Name "b" is not defined [name-defined]
1918
aliases_type_statement.py:42: error: Invalid type alias: expression is not a valid type [valid-type]
2019
aliases_type_statement.py:43: error: Invalid type alias: expression is not a valid type [valid-type]
2120
aliases_type_statement.py:44: error: Invalid type alias: expression is not a valid type [valid-type]
@@ -25,22 +24,18 @@ aliases_type_statement.py:46: error: Invalid type: try using Literal[True] inste
2524
aliases_type_statement.py:47: error: Invalid type: try using Literal[1] instead? [valid-type]
2625
aliases_type_statement.py:48: error: Invalid type alias: expression is not a valid type [valid-type]
2726
aliases_type_statement.py:49: error: Invalid type alias: expression is not a valid type [valid-type]
28-
aliases_type_statement.py:54: error: Name "BadTypeAlias14" already defined on line 52 [no-redef]
29-
aliases_type_statement.py:64: error: All type parameters should be declared ("V" not declared) [valid-type]
30-
aliases_type_statement.py:69: error: All type parameters should be declared ("T1" not declared) [valid-type]
31-
aliases_type_statement.py:79: error: Type argument "str" of "RecursiveTypeAlias2" must be a subtype of "int" [type-var]
32-
aliases_type_statement.py:81: error: Type argument "int" of "RecursiveTypeAlias2" must be a subtype of "str" [type-var]
33-
aliases_type_statement.py:84: error: Cannot resolve name "RecursiveTypeAlias3" (possible cyclic definition) [misc]
34-
aliases_type_statement.py:86: error: Invalid recursive alias: a union item of itself [misc]
35-
aliases_type_statement.py:90: error: Cannot resolve name "RecursiveTypeAlias6" (possible cyclic definition) [misc]
36-
aliases_type_statement.py:90: error: Cannot resolve name "RecursiveTypeAlias7" (possible cyclic definition) [misc]
37-
aliases_type_statement.py:91: error: Cannot resolve name "RecursiveTypeAlias7" (possible cyclic definition) [misc]
27+
aliases_type_statement.py:52: error: Name "BadTypeAlias14" already defined on line 51 [no-redef]
28+
aliases_type_statement.py:62: error: All type parameters should be declared ("V" not declared) [valid-type]
29+
aliases_type_statement.py:67: error: All type parameters should be declared ("T1" not declared) [valid-type]
30+
aliases_type_statement.py:77: error: Type argument "str" of "RecursiveTypeAlias2" must be a subtype of "int" [type-var]
31+
aliases_type_statement.py:79: error: Type argument "int" of "RecursiveTypeAlias2" must be a subtype of "str" [type-var]
32+
aliases_type_statement.py:82: error: Cannot resolve name "RecursiveTypeAlias3" (possible cyclic definition) [misc]
33+
aliases_type_statement.py:84: error: Invalid recursive alias: a union item of itself [misc]
34+
aliases_type_statement.py:88: error: Cannot resolve name "RecursiveTypeAlias6" (possible cyclic definition) [misc]
35+
aliases_type_statement.py:88: error: Cannot resolve name "RecursiveTypeAlias7" (possible cyclic definition) [misc]
36+
aliases_type_statement.py:89: error: Cannot resolve name "RecursiveTypeAlias7" (possible cyclic definition) [misc]
3837
"""
3938
conformance_automated = "Fail"
4039
errors_diff = """
41-
Line 26: Expected 1 errors
42-
Line 52: Expected 1 errors
43-
Line 58: Expected 1 errors
44-
Line 54: Unexpected errors ['aliases_type_statement.py:54: error: Name "BadTypeAlias14" already defined on line 52 [no-redef]']
45-
Line 91: Unexpected errors ['aliases_type_statement.py:91: error: Cannot resolve name "RecursiveTypeAlias7" (possible cyclic definition) [misc]']
40+
Line 56: Expected 1 errors
4641
"""

conformance/results/mypy/aliases_typealiastype.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ aliases_typealiastype.py:52: error: Invalid type alias: expression is not a vali
2323
aliases_typealiastype.py:53: error: Bracketed expression "[...]" is not valid as a type [valid-type]
2424
aliases_typealiastype.py:54: error: Invalid type alias: expression is not a valid type [valid-type]
2525
aliases_typealiastype.py:55: error: Invalid type alias: expression is not a valid type [valid-type]
26-
aliases_typealiastype.py:56: error: Invalid type alias: expression is not a valid type [valid-type]
26+
aliases_typealiastype.py:56: error: Inline TypedDict is experimental, must be enabled with --enable-incomplete-feature=InlineTypedDict [misc]
27+
aliases_typealiastype.py:56: error: Name "b" is not defined [name-defined]
2728
aliases_typealiastype.py:57: error: Invalid type alias: expression is not a valid type [valid-type]
2829
aliases_typealiastype.py:58: error: Invalid type alias: expression is not a valid type [valid-type]
2930
aliases_typealiastype.py:59: error: Invalid type alias: expression is not a valid type [valid-type]
Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,42 @@
11
conformant = "Unsupported"
22
output = """
3+
generics_defaults.py:24: error: "T" cannot appear after "DefaultStrT" in type parameter list because it has no default type [misc]
4+
generics_defaults.py:30: error: Expression is of type "type[NoNonDefaults[Any, Any]]", not "type[NoNonDefaults[str, int]]" [assert-type]
5+
generics_defaults.py:31: error: Expression is of type "type[NoNonDefaults[Any, Any]]", not "type[NoNonDefaults[str, int]]" [assert-type]
6+
generics_defaults.py:38: error: Expression is of type "type[OneDefault[Any, Any]]", not "type[OneDefault[float, bool]]" [assert-type]
7+
generics_defaults.py:45: error: Expression is of type "type[AllTheDefaults[Any, Any, Any, Any, Any]]", not "type[AllTheDefaults[Any, Any, str, int, bool]]" [assert-type]
8+
generics_defaults.py:46: error: Expression is of type "type[AllTheDefaults[Any, Any, Any, Any, Any]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]
9+
generics_defaults.py:50: error: Type application has too few types (expected between 2 and 5) [misc]
10+
generics_defaults.py:52: error: Expression is of type "type[AllTheDefaults[Any, Any, Any, Any, Any]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]
11+
generics_defaults.py:55: error: Expression is of type "type[AllTheDefaults[Any, Any, Any, Any, Any]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]
12+
generics_defaults.py:59: error: Expression is of type "type[AllTheDefaults[Any, Any, Any, Any, Any]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]
13+
generics_defaults.py:79: error: Expression is of type "type[Class_ParamSpec[Any]]", not "type[Class_ParamSpec[[str, int]]]" [assert-type]
14+
generics_defaults.py:94: error: Expression is of type "type[Class_TypeVarTuple[*tuple[Any, ...]]]", not "type[Class_TypeVarTuple[str, int]]" [assert-type]
15+
generics_defaults.py:151: error: Expression is of type "type[Foo6[*tuple[Any, ...], Any]]", not "type[Foo6[int, str, [float, bool]]]" [assert-type]
16+
generics_defaults.py:151: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [misc]
17+
generics_defaults.py:152: error: Expression is of type "type[Foo6[*tuple[Any, ...], Any]]", not "type[Foo6[int, str, [bytes]]]" [assert-type]
18+
generics_defaults.py:152: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [misc]
19+
generics_defaults.py:166: error: Expression is of type "Callable[[Self], Self]", not "Callable[[Foo7[int]], Foo7[int]]" [assert-type]
20+
generics_defaults.py:167: error: Expression is of type "Any", not "int" [assert-type]
21+
generics_defaults.py:167: error: Access to generic instance variables via class is ambiguous [misc]
322
"""
423
conformance_automated = "Fail"
524
errors_diff = """
6-
Line 24: Expected 1 errors
7-
Line 50: Expected 1 errors
825
Line 104: Expected 1 errors
926
Line 111: Expected 1 errors
1027
Line 138: Expected 1 errors
28+
Line 30: Unexpected errors ['generics_defaults.py:30: error: Expression is of type "type[NoNonDefaults[Any, Any]]", not "type[NoNonDefaults[str, int]]" [assert-type]']
29+
Line 31: Unexpected errors ['generics_defaults.py:31: error: Expression is of type "type[NoNonDefaults[Any, Any]]", not "type[NoNonDefaults[str, int]]" [assert-type]']
30+
Line 38: Unexpected errors ['generics_defaults.py:38: error: Expression is of type "type[OneDefault[Any, Any]]", not "type[OneDefault[float, bool]]" [assert-type]']
31+
Line 45: Unexpected errors ['generics_defaults.py:45: error: Expression is of type "type[AllTheDefaults[Any, Any, Any, Any, Any]]", not "type[AllTheDefaults[Any, Any, str, int, bool]]" [assert-type]']
32+
Line 46: Unexpected errors ['generics_defaults.py:46: error: Expression is of type "type[AllTheDefaults[Any, Any, Any, Any, Any]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]']
33+
Line 52: Unexpected errors ['generics_defaults.py:52: error: Expression is of type "type[AllTheDefaults[Any, Any, Any, Any, Any]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]']
34+
Line 55: Unexpected errors ['generics_defaults.py:55: error: Expression is of type "type[AllTheDefaults[Any, Any, Any, Any, Any]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]']
35+
Line 59: Unexpected errors ['generics_defaults.py:59: error: Expression is of type "type[AllTheDefaults[Any, Any, Any, Any, Any]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]']
36+
Line 79: Unexpected errors ['generics_defaults.py:79: error: Expression is of type "type[Class_ParamSpec[Any]]", not "type[Class_ParamSpec[[str, int]]]" [assert-type]']
37+
Line 94: Unexpected errors ['generics_defaults.py:94: error: Expression is of type "type[Class_TypeVarTuple[*tuple[Any, ...]]]", not "type[Class_TypeVarTuple[str, int]]" [assert-type]']
38+
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]']
39+
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]']
40+
Line 166: Unexpected errors ['generics_defaults.py:166: error: Expression is of type "Callable[[Self], Self]", not "Callable[[Foo7[int]], Foo7[int]]" [assert-type]']
41+
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]']
1142
"""

conformance/results/mypy/generics_paramspec_components.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Does not report illegal use of "P.args" on normal parameter.
44
Does not report error when P.args is specified but P.kwargs is missing.
55
Does not report error when P is out of scope and P.args and P.kwargs is used.
66
Does not report error when keyword argument is specified between P.args and P.kwargs.
7-
Does not report error when calling callable and argument is missing for concatenated parameters.
87
"""
98
output = """
109
generics_paramspec_components.py:17: error: Use "P.args" for variadic "*" parameter [valid-type]
@@ -15,6 +14,7 @@ generics_paramspec_components.py:49: error: Argument 2 has incompatible type "**
1514
generics_paramspec_components.py:51: error: Argument 1 has incompatible type "int"; expected "P.args" [arg-type]
1615
generics_paramspec_components.py:70: error: Argument 1 has incompatible type "*P.args"; expected "int" [arg-type]
1716
generics_paramspec_components.py:70: error: Argument 2 has incompatible type "int"; expected "P.args" [arg-type]
17+
generics_paramspec_components.py:72: error: Argument 1 has incompatible type "*P.args"; expected "int" [arg-type]
1818
generics_paramspec_components.py:83: error: "foo" gets multiple values for keyword argument "x" [misc]
1919
generics_paramspec_components.py:83: error: Argument 1 to "foo" has incompatible type "*P.args"; expected "int" [arg-type]
2020
generics_paramspec_components.py:83: error: Argument 3 to "foo" has incompatible type "**P.kwargs"; expected "int" [arg-type]
@@ -31,5 +31,4 @@ Line 36: Expected 1 errors
3131
Line 38: Expected 1 errors
3232
Line 41: Expected 1 errors
3333
Line 60: Expected 1 errors
34-
Line 72: Expected 1 errors
3534
"""
Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
conformant = "Partial"
2-
notes = """
3-
Does not detect many illegal usages of type parameter syntax.
4-
"""
1+
conformant = "Pass"
52
output = """
3+
generics_syntax_declarations.py:17: error: Generic[...] base class is redundant [misc]
4+
generics_syntax_declarations.py:25: error: No arguments expected for "Protocol" base class [misc]
5+
generics_syntax_declarations.py:32: error: "T" has no attribute "is_integer" [attr-defined]
6+
generics_syntax_declarations.py:44: error: Name "V" is not defined [name-defined]
7+
generics_syntax_declarations.py:48: error: Bracketed expression "[...]" is not valid as a type [valid-type]
8+
generics_syntax_declarations.py:60: error: Type variable must have at least two constrained types [misc]
9+
generics_syntax_declarations.py:64: error: Type variable must have at least two constrained types [misc]
10+
generics_syntax_declarations.py:71: error: Variable "generics_syntax_declarations.t1" is not valid as a type [valid-type]
11+
generics_syntax_declarations.py:71: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
12+
generics_syntax_declarations.py:75: error: Invalid type: try using Literal[3] instead? [valid-type]
13+
generics_syntax_declarations.py:79: error: Name "S" is not defined [name-defined]
614
"""
7-
conformance_automated = "Fail"
15+
conformance_automated = "Pass"
816
errors_diff = """
9-
Line 19: Expected 1 errors
10-
Line 27: Expected 1 errors
11-
Line 34: Expected 1 errors
12-
Line 46: Expected 1 errors
13-
Line 50: Expected 1 errors
14-
Line 62: Expected 1 errors
15-
Line 66: Expected 1 errors
16-
Line 73: Expected 1 errors
17-
Line 77: Expected 1 errors
18-
Line 81: Expected 1 errors
1917
"""

0 commit comments

Comments
 (0)