Skip to content

Commit be7ba97

Browse files
authored
Implemented conformance tests for imported Final variables (#1942)
Implemented conformance tests for typing spec involving imported Final variables.
1 parent 811a867 commit be7ba97

17 files changed

+96
-37
lines changed

conformance/results/mypy/annotations_generators.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ annotations_generators.py:71: error: No return value expected [return-value]
1111
annotations_generators.py:75: error: Incompatible types in "yield" (actual type "B", expected type "A") [misc]
1212
annotations_generators.py:86: error: The return type of a generator function should be "Generator" or one of its supertypes [misc]
1313
annotations_generators.py:91: error: The return type of an async generator function should be "AsyncGenerator" or one of its supertypes [misc]
14-
annotations_generators.py:116: error: Incompatible types in "yield from" (actual type "A", expected type "B") [misc]
15-
annotations_generators.py:117: error: Incompatible types in "yield from" (actual type "int", expected type "B") [misc]
14+
annotations_generators.py:118: error: Incompatible types in "yield from" (actual type "A", expected type "B") [misc]
15+
annotations_generators.py:119: error: Incompatible types in "yield from" (actual type "int", expected type "B") [misc]
1616
"""
1717
conformance_automated = "Fail"
1818
errors_diff = """
1919
Line 87: Expected 1 errors
2020
Line 92: Expected 1 errors
21-
Line 133: Expected 1 errors
21+
Line 135: Expected 1 errors
2222
"""

conformance/results/mypy/qualifiers_final_annotation.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ qualifiers_final_annotation.py:145: error: Cannot assign to final name "x" [mis
3535
qualifiers_final_annotation.py:147: error: Cannot assign to final name "x" [misc]
3636
qualifiers_final_annotation.py:152: error: Incompatible types in assignment (expression has type "TextIOWrapper[_WrappedBuffer]", variable has type "int") [assignment]
3737
qualifiers_final_annotation.py:155: error: Cannot assign to final name "x" [misc]
38+
qualifiers_final_annotation.py:166: error: Cannot assign to final name "TEN" [misc]
39+
qualifiers_final_annotation.py:170: error: Cannot assign to final name "PI" [misc]
3840
"""
3941
conformance_automated = "Fail"
4042
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.15.0"
2-
test_duration = 1.8
2+
test_duration = 1.7

conformance/results/pyre/annotations_generators.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ annotations_generators.py:87:4 Incompatible return type [7]: Expected `int` but
1212
annotations_generators.py:88:4 Incompatible return type [7]: Expected `int` but got `Generator[typing.Any, typing.Any, int]`.
1313
annotations_generators.py:91:0 Incompatible async generator return type [57]: Expected return annotation to be AsyncGenerator or a superclass but got `int`.
1414
annotations_generators.py:92:4 Incompatible return type [7]: Expected `int` but got `AsyncGenerator[None, typing.Any]`.
15-
annotations_generators.py:116:4 Incompatible return type [7]: Expected `Iterator[B]` but got `Generator[A, None, typing.Any]`.
16-
annotations_generators.py:117:4 Incompatible return type [7]: Expected `Iterator[B]` but got `Generator[int, None, typing.Any]`.
17-
annotations_generators.py:133:4 Incompatible return type [7]: Expected `Generator[None, str, None]` but got `Generator[None, int, typing.Any]`.
18-
annotations_generators.py:183:0 Incompatible variable type [9]: v1 is declared to have type `typing.Callable[[], Coroutine[typing.Any, typing.Any, AsyncIterator[int]]]` but is used as type `typing.Callable(generator29)[[], AsyncIterator[int]]`.
15+
annotations_generators.py:118:4 Incompatible return type [7]: Expected `Iterator[B]` but got `Generator[A, None, typing.Any]`.
16+
annotations_generators.py:119:4 Incompatible return type [7]: Expected `Iterator[B]` but got `Generator[int, None, typing.Any]`.
17+
annotations_generators.py:135:4 Incompatible return type [7]: Expected `Generator[None, str, None]` but got `Generator[None, int, typing.Any]`.
18+
annotations_generators.py:185:0 Incompatible variable type [9]: v1 is declared to have type `typing.Callable[[], Coroutine[typing.Any, typing.Any, AsyncIterator[int]]]` but is used as type `typing.Callable(generator29)[[], AsyncIterator[int]]`.
1919
"""
2020
conformance_automated = "Fail"
2121
errors_diff = """
2222
Line 51: Expected 1 errors
2323
Line 86: Expected 1 errors
2424
Line 88: Unexpected errors ['annotations_generators.py:88:4 Incompatible return type [7]: Expected `int` but got `Generator[typing.Any, typing.Any, int]`.']
25-
Line 183: Unexpected errors ['annotations_generators.py:183:0 Incompatible variable type [9]: v1 is declared to have type `typing.Callable[[], Coroutine[typing.Any, typing.Any, AsyncIterator[int]]]` but is used as type `typing.Callable(generator29)[[], AsyncIterator[int]]`.']
25+
Line 185: Unexpected errors ['annotations_generators.py:185:0 Incompatible variable type [9]: v1 is declared to have type `typing.Callable[[], Coroutine[typing.Any, typing.Any, AsyncIterator[int]]]` but is used as type `typing.Callable(generator29)[[], AsyncIterator[int]]`.']
2626
"""

conformance/results/pyre/qualifiers_final_annotation.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ notes = """
33
Does not report Final variable with missing initialization in module scope.
44
Does not report error for invalid nesting of Final and ClassVar.
55
Does not treat use of Final name as if it was replaced by the literal in NamedTuple definition.
6+
Does not reject modification of imported variable declared Final.
67
"""
78
output = """
89
qualifiers_final_annotation.py:18:6 Invalid type parameters [24]: Generic type `Final` expects 1 type parameter, received 2.
@@ -33,5 +34,7 @@ errors_diff = """
3334
Line 16: Expected 1 errors
3435
Line 107: Expected 1 errors
3536
Line 108: Expected 1 errors
37+
Line 166: Expected 1 errors
38+
Line 170: Expected 1 errors
3639
Line 133: Unexpected errors ['qualifiers_final_annotation.py:133:0 Unexpected keyword [28]: Unexpected keyword argument `x` to call `N.__init__`.']
3740
"""

conformance/results/pyre/version.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version = "pyre 0.9.23"
2-
test_duration = 6.5
2+
test_duration = 6.8

conformance/results/pyright/annotations_generators.toml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ annotations_generators.py:51:21 - error: Function with declared return type "C"
55
annotations_generators.py:54:16 - error: Type "Literal[False]" is not assignable to return type "C"
66
  "Literal[False]" is not assignable to "C" (reportReturnType)
77
annotations_generators.py:57:15 - error: Return type of generator function must be compatible with "Generator[Literal[3], Any, Any]"
8-
  "Literal[3]" is not assignable to "A" (reportReturnType)
8+
  "Generator[Literal[3], Unknown, Unknown]" is not assignable to "Generator[A, B, C]"
9+
    Type parameter "_YieldT_co@Generator" is covariant, but "Literal[3]" is not a subtype of "A"
10+
      "Literal[3]" is not assignable to "A" (reportReturnType)
911
annotations_generators.py:66:15 - error: Return type of generator function must be compatible with "Generator[Literal[3], Any, Any]"
10-
  "Literal[3]" is not assignable to "A" (reportReturnType)
12+
  "Generator[Literal[3], Unknown, Unknown]" is not assignable to "Generator[A, int, Any]"
13+
    Type parameter "_YieldT_co@Generator" is covariant, but "Literal[3]" is not a subtype of "A"
14+
      "Literal[3]" is not assignable to "A" (reportReturnType)
1115
annotations_generators.py:75:11 - error: Return type of generator function must be compatible with "Generator[B, Any, Any]"
12-
  "B" is not assignable to "A" (reportReturnType)
16+
  "Generator[B, Unknown, Unknown]" is not assignable to "Iterator[A]"
17+
    Type parameter "_T_co@Iterator" is covariant, but "B" is not a subtype of "A"
18+
      "B" is not assignable to "A" (reportReturnType)
1319
annotations_generators.py:86:21 - error: Return type of generator function must be compatible with "Generator[Any, Any, Any]"
1420
  "Generator[Any, Any, Any]" is not assignable to "int" (reportInvalidTypeForm)
1521
annotations_generators.py:87:11 - error: Return type of generator function must be compatible with "Generator[None, Any, Any]"
@@ -18,15 +24,15 @@ annotations_generators.py:91:27 - error: Return type of async generator function
1824
  "AsyncGenerator[Any, Any, Any]" is not assignable to "int" (reportInvalidTypeForm)
1925
annotations_generators.py:92:11 - error: Return type of async generator function must be compatible with "AsyncGenerator[None, Any]"
2026
  "AsyncGenerator[None, Unknown, Unknown]" is not assignable to "int" (reportReturnType)
21-
annotations_generators.py:116:16 - error: Return type of generator function must be compatible with "Generator[A, Any, Any]"
27+
annotations_generators.py:118:16 - error: Return type of generator function must be compatible with "Generator[A, Any, Any]"
2228
  "Generator[A, Unknown, Unknown]" is not assignable to "Iterator[B]"
2329
    Type parameter "_T_co@Iterator" is covariant, but "A" is not a subtype of "B"
2430
      "A" is not assignable to "B" (reportReturnType)
25-
annotations_generators.py:117:16 - error: Return type of generator function must be compatible with "Generator[int, Any, Any]"
31+
annotations_generators.py:119:16 - error: Return type of generator function must be compatible with "Generator[int, Any, Any]"
2632
  "Generator[int, Unknown, Unknown]" is not assignable to "Iterator[B]"
2733
    Type parameter "_T_co@Iterator" is covariant, but "int" is not a subtype of "B"
2834
      "int" is not assignable to "B" (reportReturnType)
29-
annotations_generators.py:133:16 - error: Return type of generator function must be compatible with "Generator[None, Any, Any]"
35+
annotations_generators.py:135:16 - error: Return type of generator function must be compatible with "Generator[None, Any, Any]"
3036
  "Generator[None, int, Unknown]" is not assignable to "Generator[None, str, None]"
3137
    Type parameter "_SendT_contra@Generator" is contravariant, but "int" is not a supertype of "str"
3238
      "str" is not assignable to "int" (reportReturnType)

conformance/results/pyright/callables_subtyping.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ callables_subtyping.py:119:23 - error: Type "StrArgs4" is not assignable to decl
6767
  "StrArgs4" is incompatible with protocol "IntStrArgs4"
6868
    "__call__" is an incompatible type
6969
      Type "(a: int, /, *args: str) -> None" is not assignable to type "(*args: int | str) -> None"
70+
        Parameter 1: type "int | str" is incompatible with type "int"
71+
          Type "int | str" is not assignable to type "int"
7072
        Parameter 2: type "int | str" is incompatible with type "str"
7173
          Type "int | str" is not assignable to type "str"
7274
        Parameter 1: type "*tuple[int | str, ...]" is incompatible with type "*tuple[str, ...]"
73-
          "*tuple[int | str, ...]" is not assignable to "*tuple[str, ...]" (reportAssignmentType)
75+
... (reportAssignmentType)
7476
callables_subtyping.py:120:23 - error: Type "IntArgs4" is not assignable to declared type "IntStrArgs4"
7577
  "IntArgs4" is incompatible with protocol "IntStrArgs4"
7678
    "__call__" is an incompatible type

conformance/results/pyright/qualifiers_final_annotation.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ qualifiers_final_annotation.py:147:10 - error: "x" is declared as Final and cann
3737
qualifiers_final_annotation.py:149:9 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues)
3838
qualifiers_final_annotation.py:152:30 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues)
3939
qualifiers_final_annotation.py:155:9 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues)
40+
qualifiers_final_annotation.py:166:1 - error: "TEN" is declared as Final and cannot be reassigned (reportGeneralTypeIssues)
41+
qualifiers_final_annotation.py:170:1 - error: "PI" is declared as Final and cannot be reassigned (reportGeneralTypeIssues)
4042
"""
4143
conformance_automated = "Pass"
4244
errors_diff = """
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version = "pyright 1.1.394"
1+
version = "pyright 1.1.396"
22
test_duration = 1.3

0 commit comments

Comments
 (0)