Skip to content

Commit cbedd6d

Browse files
authored
Update conformance tests for recent generics spec change (#1892)
* Baseline changes * New test cases for generics_base_class. * New test cases in generics_basic.
1 parent 438dc29 commit cbedd6d

19 files changed

+142
-35
lines changed

conformance/results/mypy/generics_base_class.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
conformant = "Pass"
1+
conformant = "Partial"
2+
notes = """
3+
Does not detect inconsistent type variable ordering.
4+
"""
25
output = """
36
generics_base_class.py:26: error: Argument 1 to "takes_dict_incorrect" has incompatible type "SymbolTable"; expected "dict[str, list[object]]" [arg-type]
47
generics_base_class.py:29: error: Variable "typing.Generic" is not valid as a type [valid-type]
@@ -9,6 +12,7 @@ generics_base_class.py:49: error: "LinkedList" expects 1 type argument, but 2 gi
912
generics_base_class.py:61: error: "MyDict" expects 1 type argument, but 2 given [type-arg]
1013
generics_base_class.py:68: error: Duplicate type variables in Generic[...] or Protocol[...] [misc]
1114
"""
12-
conformance_automated = "Pass"
15+
conformance_automated = "Fail"
1316
errors_diff = """
17+
Line 98: Expected 1 errors
1418
"""

conformance/results/mypy/generics_basic.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ generics_basic.py:69: error: Value of type variable "AnyStr" of "concat" cannot
1010
generics_basic.py:121: error: Duplicate type variables in Generic[...] or Protocol[...] [misc]
1111
generics_basic.py:157: error: Invalid index type "int" for "MyMap1[str, int]"; expected type "str" [index]
1212
generics_basic.py:158: error: Invalid index type "int" for "MyMap2[int, str]"; expected type "str" [index]
13-
generics_basic.py:191: error: Dynamic metaclass not supported for "GenericMetaInstance" [misc]
14-
generics_basic.py:191: error: Type variable "generics_basic.T" is unbound [valid-type]
15-
generics_basic.py:191: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class)
16-
generics_basic.py:191: note: (Hint: Use "T" in function signature to bind "T" inside a function)
13+
generics_basic.py:162: error: Free type variable expected in Generic[...] [misc]
14+
generics_basic.py:163: error: Free type variable expected in Protocol[...] [misc]
15+
generics_basic.py:171: error: If Generic[...] or Protocol[...] is present it should list all type variables [misc]
16+
generics_basic.py:172: error: If Generic[...] or Protocol[...] is present it should list all type variables [misc]
17+
generics_basic.py:208: error: Dynamic metaclass not supported for "GenericMetaInstance" [misc]
18+
generics_basic.py:208: error: Type variable "generics_basic.T" is unbound [valid-type]
19+
generics_basic.py:208: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class)
20+
generics_basic.py:208: note: (Hint: Use "T" in function signature to bind "T" inside a function)
1721
"""
1822
conformance_automated = "Fail"
1923
errors_diff = """

conformance/results/mypy/version.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version = "mypy 1.13.0"
2-
test_duration = 2.7
2+
test_duration = 2.5

conformance/results/pyre/generics_base_class.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ conformant = "Partial"
22
notes = """
33
Does not reject illegal use of Generic.
44
Does not allow using generic in assert_type expression.
5+
Does not detect inconsistent type variable ordering.
56
"""
67
output = """
78
generics_base_class.py:26:25 Incompatible parameter type [6]: In call `takes_dict_incorrect`, for 1st positional argument, expected `Dict[str, List[object]]` but got `SymbolTable`.
@@ -13,4 +14,5 @@ conformance_automated = "Fail"
1314
errors_diff = """
1415
Line 29: Expected 1 errors
1516
Line 30: Expected 1 errors
17+
Line 98: Expected 1 errors
1618
"""

conformance/results/pyre/generics_basic.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ False positives in examples using constrained type variables.
44
False negative for constraint parameterized by a type variable.
55
False negative in custom map example.
66
False positive using `iter`.
7+
False negative for bad type arguments to Generic/Protocol.
78
False negative for generic metaclass.
89
"""
910
output = """
@@ -16,10 +17,14 @@ generics_basic.py:69:14 Incompatible parameter type [6]: In call `concat`, for 2
1617
generics_basic.py:121:0 Duplicate type variables [59]: Duplicate type variable `T` in Generic[...].
1718
generics_basic.py:157:7 Incompatible parameter type [6]: In call `typing.Mapping.__getitem__`, for 1st positional argument, expected `str` but got `int`.
1819
generics_basic.py:158:7 Incompatible parameter type [6]: In call `typing.Mapping.__getitem__`, for 1st positional argument, expected `str` but got `int`.
20+
generics_basic.py:171:11 Invalid type variable [34]: The current class isn't generic with respect to the type variable `Variable[T_co]`. To reference the type variable, you can modify the class to inherit from `typing.Generic[T_co]`.
21+
generics_basic.py:172:11 Invalid type variable [34]: The current class isn't generic with respect to the type variable `Variable[T_co]`. To reference the type variable, you can modify the class to inherit from `typing.Generic[T_co]`.
1922
"""
2023
conformance_automated = "Fail"
2124
errors_diff = """
2225
Line 55: Expected 1 errors
23-
Line 191: Expected 1 errors
26+
Line 162: Expected 1 errors
27+
Line 163: Expected 1 errors
28+
Line 208: Expected 1 errors
2429
Line 34: Unexpected errors ['generics_basic.py:34:4 Incompatible return type [7]: Expected `Variable[AnyStr <: [str, bytes]]` but got `str`.', 'generics_basic.py:34:15 Incompatible parameter type [6]: In call `str.__add__`, for 1st positional argument, expected `str` but got `Variable[AnyStr <: [str, bytes]]`.']
2530
"""

conformance/results/pyre/version.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
version = "pyre 0.9.23"
2-
test_duration = 9.1
3-
2+
test_duration = 4.3

conformance/results/pyright/dataclasses_transform_converter.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ dataclasses_transform_converter.py:130:67 - error: Argument of type "Literal[1]"
4040
dataclasses_transform_converter.py:133:75 - error: Argument of type "type[int]" cannot be assigned to parameter "default_factory" of type "(() -> S@model_field) | None" in function "model_field"
4141
  Type "type[int]" is not assignable to type "(() -> str) | None"
4242
    No overloaded function matches type "() -> str"
43-
    "type[type]" is not assignable to "type[None]" (reportArgumentType)
43+
    Type is not assignable to "None" (reportArgumentType)
4444
"""

conformance/results/pyright/generics_base_class.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ generics_base_class.py:30:8 - error: "Generic" is not valid in this context (rep
1010
generics_base_class.py:49:38 - error: Too many type arguments provided for "LinkedList"; expected 1 but received 2 (reportInvalidTypeArguments)
1111
generics_base_class.py:61:30 - error: Too many type arguments provided for "MyDict"; expected 1 but received 2 (reportInvalidTypeArguments)
1212
generics_base_class.py:68:28 - error: Type arguments for "Generic" must be unique (reportInvalidTypeForm)
13+
generics_base_class.py:98:7 - error: Base classes of BadChild are mutually incompatible
14+
  Base class "Grandparent[T2@BadChild, T1@BadChild]" derives from "Grandparent[T2@BadChild, T1@BadChild]" which is incompatible with type "Grandparent[T1@BadChild, T2@BadChild]" (reportGeneralTypeIssues)
1315
"""
1416
conformance_automated = "Pass"
1517
errors_diff = """

conformance/results/pyright/generics_basic.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ generics_basic.py:157:5 - error: Argument of type "Literal[0]" cannot be assigne
1313
  "Literal[0]" is not assignable to "str" (reportArgumentType)
1414
generics_basic.py:158:5 - error: Argument of type "Literal[0]" cannot be assigned to parameter "key" of type "str" in function "__getitem__"
1515
  "Literal[0]" is not assignable to "str" (reportArgumentType)
16-
generics_basic.py:191:37 - error: Metaclass cannot be generic (reportGeneralTypeIssues)
16+
generics_basic.py:162:20 - error: Type argument for "Generic" must be a type variable (reportInvalidTypeForm)
17+
generics_basic.py:163:21 - error: Type argument for "Protocol" must be a type parameter (reportInvalidTypeForm)
18+
generics_basic.py:171:7 - error: Generic[] or Protocol[] must include all type variables
19+
  Missing type variables: "T_co" (reportGeneralTypeIssues)
20+
generics_basic.py:172:7 - error: Generic[] or Protocol[] must include all type variables
21+
  Missing type variables: "T_co" (reportGeneralTypeIssues)
22+
generics_basic.py:208:37 - error: Metaclass cannot be generic (reportGeneralTypeIssues)
1723
"""
1824
conformance_automated = "Pass"
1925
errors_diff = """

conformance/results/pyright/overloads_basic.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
conformant = "Pass"
22
output = """
33
overloads_basic.py:37:1 - error: No overloads for "__getitem__" match the provided arguments (reportCallIssue)
4-
overloads_basic.py:37:1 - error: Argument of type "Literal['']" cannot be assigned to parameter "__s" of type "slice" in function "__getitem__"
5-
  "Literal['']" is not assignable to "slice" (reportArgumentType)
4+
overloads_basic.py:37:1 - error: Argument of type "Literal['']" cannot be assigned to parameter "__s" of type "slice[Any, Any, Any]" in function "__getitem__"
5+
  "Literal['']" is not assignable to "slice[Any, Any, Any]" (reportArgumentType)
66
overloads_basic.py:63:5 - error: "func1" is marked as overload, but additional overloads are missing (reportInconsistentOverload)
77
overloads_basic.py:75:5 - error: "func2" is marked as overload, but no implementation is provided (reportNoOverloadImplementation)
88
"""

0 commit comments

Comments
 (0)