Skip to content

Commit

Permalink
Updated conformance results for mypy 1.12. (#1866)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
erictraut authored Oct 15, 2024
1 parent c5e52dd commit f86459c
Show file tree
Hide file tree
Showing 33 changed files with 198 additions and 285 deletions.
3 changes: 2 additions & 1 deletion conformance/results/mypy/aliases_explicit.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ aliases_explicit.py:79: error: Invalid type alias: expression is not a valid typ
aliases_explicit.py:80: error: Bracketed expression "[...]" is not valid as a type [valid-type]
aliases_explicit.py:81: error: Invalid type alias: expression is not a valid type [valid-type]
aliases_explicit.py:82: error: Invalid type alias: expression is not a valid type [valid-type]
aliases_explicit.py:83: error: Invalid type alias: expression is not a valid type [valid-type]
aliases_explicit.py:83: error: Inline TypedDict is experimental, must be enabled with --enable-incomplete-feature=InlineTypedDict [misc]
aliases_explicit.py:83: error: Name "b" is not defined [name-defined]
aliases_explicit.py:84: error: Invalid type alias: expression is not a valid type [valid-type]
aliases_explicit.py:85: error: Invalid type alias: expression is not a valid type [valid-type]
aliases_explicit.py:86: error: Invalid type alias: expression is not a valid type [valid-type]
Expand Down
33 changes: 14 additions & 19 deletions conformance/results/mypy/aliases_type_statement.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
conformant = "Partial"
notes = """
Does not reject use of TypeAliasType as base class.
Does not reject redefinition of type alias defined with type statement.
Does not reject type alias defined in function scope.
Does not reject type alias with circular definition.
"""
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]
aliases_type_statement.py:23: error: "TypeAliasType" has no attribute "other_attrib" [attr-defined]
aliases_type_statement.py:26: error: Type alias defined using "type" statement not valid as base class [misc]
aliases_type_statement.py:31: error: Parameterized generics cannot be used with class or instance checks [misc]
aliases_type_statement.py:31: error: Argument 2 to "isinstance" has incompatible type "TypeAliasType"; expected "_ClassInfo" [arg-type]
aliases_type_statement.py:37: error: Invalid type alias: expression is not a valid type [valid-type]
aliases_type_statement.py:38: error: Bracketed expression "[...]" is not valid as a type [valid-type]
aliases_type_statement.py:39: error: Invalid type alias: expression is not a valid type [valid-type]
aliases_type_statement.py:40: error: Invalid type alias: expression is not a valid type [valid-type]
aliases_type_statement.py:41: error: Invalid type alias: expression is not a valid type [valid-type]
aliases_type_statement.py:41: error: Inline TypedDict is experimental, must be enabled with --enable-incomplete-feature=InlineTypedDict [misc]
aliases_type_statement.py:41: error: Name "b" is not defined [name-defined]
aliases_type_statement.py:42: error: Invalid type alias: expression is not a valid type [valid-type]
aliases_type_statement.py:43: error: Invalid type alias: expression is not a valid type [valid-type]
aliases_type_statement.py:44: error: Invalid type alias: expression is not a valid type [valid-type]
Expand All @@ -25,22 +24,18 @@ 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:54: error: Name "BadTypeAlias14" already defined on line 52 [no-redef]
aliases_type_statement.py:64: error: All type parameters should be declared ("V" not declared) [valid-type]
aliases_type_statement.py:69: error: All type parameters should be declared ("T1" not declared) [valid-type]
aliases_type_statement.py:79: error: Type argument "str" of "RecursiveTypeAlias2" must be a subtype of "int" [type-var]
aliases_type_statement.py:81: error: Type argument "int" of "RecursiveTypeAlias2" must be a subtype of "str" [type-var]
aliases_type_statement.py:84: error: Cannot resolve name "RecursiveTypeAlias3" (possible cyclic definition) [misc]
aliases_type_statement.py:86: error: Invalid recursive alias: a union item of itself [misc]
aliases_type_statement.py:90: error: Cannot resolve name "RecursiveTypeAlias6" (possible cyclic definition) [misc]
aliases_type_statement.py:90: error: Cannot resolve name "RecursiveTypeAlias7" (possible cyclic definition) [misc]
aliases_type_statement.py:91: error: Cannot resolve name "RecursiveTypeAlias7" (possible cyclic definition) [misc]
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]
"""
conformance_automated = "Fail"
errors_diff = """
Line 26: Expected 1 errors
Line 52: Expected 1 errors
Line 58: Expected 1 errors
Line 54: Unexpected errors ['aliases_type_statement.py:54: error: Name "BadTypeAlias14" already defined on line 52 [no-redef]']
Line 91: Unexpected errors ['aliases_type_statement.py:91: error: Cannot resolve name "RecursiveTypeAlias7" (possible cyclic definition) [misc]']
Line 56: Expected 1 errors
"""
3 changes: 2 additions & 1 deletion conformance/results/mypy/aliases_typealiastype.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ aliases_typealiastype.py:52: error: Invalid type alias: expression is not a vali
aliases_typealiastype.py:53: error: Bracketed expression "[...]" is not valid as a type [valid-type]
aliases_typealiastype.py:54: error: Invalid type alias: expression is not a valid type [valid-type]
aliases_typealiastype.py:55: error: Invalid type alias: expression is not a valid type [valid-type]
aliases_typealiastype.py:56: error: Invalid type alias: expression is not a valid type [valid-type]
aliases_typealiastype.py:56: error: Inline TypedDict is experimental, must be enabled with --enable-incomplete-feature=InlineTypedDict [misc]
aliases_typealiastype.py:56: error: Name "b" is not defined [name-defined]
aliases_typealiastype.py:57: error: Invalid type alias: expression is not a valid type [valid-type]
aliases_typealiastype.py:58: error: Invalid type alias: expression is not a valid type [valid-type]
aliases_typealiastype.py:59: error: Invalid type alias: expression is not a valid type [valid-type]
Expand Down
35 changes: 33 additions & 2 deletions conformance/results/mypy/generics_defaults.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,42 @@
conformant = "Unsupported"
output = """
generics_defaults.py:24: error: "T" cannot appear after "DefaultStrT" in type parameter list because it has no default type [misc]
generics_defaults.py:30: error: Expression is of type "type[NoNonDefaults[Any, Any]]", not "type[NoNonDefaults[str, int]]" [assert-type]
generics_defaults.py:31: error: Expression is of type "type[NoNonDefaults[Any, Any]]", not "type[NoNonDefaults[str, int]]" [assert-type]
generics_defaults.py:38: error: Expression is of type "type[OneDefault[Any, Any]]", not "type[OneDefault[float, bool]]" [assert-type]
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]
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]
generics_defaults.py:50: error: Type application has too few types (expected between 2 and 5) [misc]
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]
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]
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]
generics_defaults.py:79: error: Expression is of type "type[Class_ParamSpec[Any]]", not "type[Class_ParamSpec[[str, int]]]" [assert-type]
generics_defaults.py:94: error: Expression is of type "type[Class_TypeVarTuple[*tuple[Any, ...]]]", not "type[Class_TypeVarTuple[str, int]]" [assert-type]
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]
"""
conformance_automated = "Fail"
errors_diff = """
Line 24: Expected 1 errors
Line 50: Expected 1 errors
Line 104: Expected 1 errors
Line 111: Expected 1 errors
Line 138: Expected 1 errors
Line 30: Unexpected errors ['generics_defaults.py:30: error: Expression is of type "type[NoNonDefaults[Any, Any]]", not "type[NoNonDefaults[str, int]]" [assert-type]']
Line 31: Unexpected errors ['generics_defaults.py:31: error: Expression is of type "type[NoNonDefaults[Any, Any]]", not "type[NoNonDefaults[str, int]]" [assert-type]']
Line 38: Unexpected errors ['generics_defaults.py:38: error: Expression is of type "type[OneDefault[Any, Any]]", not "type[OneDefault[float, bool]]" [assert-type]']
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]']
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]']
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]']
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]']
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]']
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]']
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]']
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]']
"""
3 changes: 1 addition & 2 deletions conformance/results/mypy/generics_paramspec_components.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Does not report illegal use of "P.args" on normal parameter.
Does not report error when P.args is specified but P.kwargs is missing.
Does not report error when P is out of scope and P.args and P.kwargs is used.
Does not report error when keyword argument is specified between P.args and P.kwargs.
Does not report error when calling callable and argument is missing for concatenated parameters.
"""
output = """
generics_paramspec_components.py:17: error: Use "P.args" for variadic "*" parameter [valid-type]
Expand All @@ -15,6 +14,7 @@ generics_paramspec_components.py:49: error: Argument 2 has incompatible type "**
generics_paramspec_components.py:51: error: Argument 1 has incompatible type "int"; expected "P.args" [arg-type]
generics_paramspec_components.py:70: error: Argument 1 has incompatible type "*P.args"; expected "int" [arg-type]
generics_paramspec_components.py:70: error: Argument 2 has incompatible type "int"; expected "P.args" [arg-type]
generics_paramspec_components.py:72: error: Argument 1 has incompatible type "*P.args"; expected "int" [arg-type]
generics_paramspec_components.py:83: error: "foo" gets multiple values for keyword argument "x" [misc]
generics_paramspec_components.py:83: error: Argument 1 to "foo" has incompatible type "*P.args"; expected "int" [arg-type]
generics_paramspec_components.py:83: error: Argument 3 to "foo" has incompatible type "**P.kwargs"; expected "int" [arg-type]
Expand All @@ -31,5 +31,4 @@ Line 36: Expected 1 errors
Line 38: Expected 1 errors
Line 41: Expected 1 errors
Line 60: Expected 1 errors
Line 72: Expected 1 errors
"""
28 changes: 13 additions & 15 deletions conformance/results/mypy/generics_syntax_declarations.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
conformant = "Partial"
notes = """
Does not detect many illegal usages of type parameter syntax.
"""
conformant = "Pass"
output = """
generics_syntax_declarations.py:17: error: Generic[...] base class is redundant [misc]
generics_syntax_declarations.py:25: error: No arguments expected for "Protocol" base class [misc]
generics_syntax_declarations.py:32: error: "T" has no attribute "is_integer" [attr-defined]
generics_syntax_declarations.py:44: error: Name "V" is not defined [name-defined]
generics_syntax_declarations.py:48: error: Bracketed expression "[...]" is not valid as a type [valid-type]
generics_syntax_declarations.py:60: error: Type variable must have at least two constrained types [misc]
generics_syntax_declarations.py:64: error: Type variable must have at least two constrained types [misc]
generics_syntax_declarations.py:71: error: Variable "generics_syntax_declarations.t1" is not valid as a type [valid-type]
generics_syntax_declarations.py:71: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
generics_syntax_declarations.py:75: error: Invalid type: try using Literal[3] instead? [valid-type]
generics_syntax_declarations.py:79: error: Name "S" is not defined [name-defined]
"""
conformance_automated = "Fail"
conformance_automated = "Pass"
errors_diff = """
Line 19: Expected 1 errors
Line 27: Expected 1 errors
Line 34: Expected 1 errors
Line 46: Expected 1 errors
Line 50: Expected 1 errors
Line 62: Expected 1 errors
Line 66: Expected 1 errors
Line 73: Expected 1 errors
Line 77: Expected 1 errors
Line 81: Expected 1 errors
"""
Loading

0 comments on commit f86459c

Please sign in to comment.