Skip to content

Commit 05b979d

Browse files
authored
Updated conformance tests for pyright 1.1.394. (#1926)
This version of pyright fixes a conformance issue detected by the `callables_kwargs` test. Also updated the `annotations_generatosr` and `annotations_coroutines` test cases to accommodate a more precise (narrower) type inferred for `async def` functions. Pyright now infers `types.CoroutineType` rather than `typing.Coroutine`. Both are correct and should be accepted by the test.
1 parent 7da7f02 commit 05b979d

12 files changed

+41
-36
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: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]
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]
1616
"""
1717
conformance_automated = "Fail"
1818
errors_diff = """
1919
Line 87: Expected 1 errors
2020
Line 92: Expected 1 errors
21-
Line 135: Expected 1 errors
21+
Line 133: Expected 1 errors
2222
"""

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.2
2+
test_duration = 1.8

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: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:182:0 Assert type [70]: Expected `typing.Callable[[], Coroutine[typing.Any, typing.Any, AsyncIterator[int]]]` but got `typing.Callable(generator29)[[], AsyncIterator[int]]`.
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]]`.
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 182: Unexpected errors ['annotations_generators.py:182:0 Assert type [70]: Expected `typing.Callable[[], Coroutine[typing.Any, typing.Any, AsyncIterator[int]]]` but got `typing.Callable(generator29)[[], AsyncIterator[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]]`.']
2626
"""

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 = 7.8
2+
test_duration = 6.5

conformance/results/pyright/annotations_generators.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ annotations_generators.py:91:27 - error: Return type of async generator function
1818
  "AsyncGenerator[Any, Any, Any]" is not assignable to "int" (reportInvalidTypeForm)
1919
annotations_generators.py:92:11 - error: Return type of async generator function must be compatible with "AsyncGenerator[None, Any]"
2020
  "AsyncGenerator[None, Unknown, Unknown]" is not assignable to "int" (reportReturnType)
21-
annotations_generators.py:118:16 - error: Return type of generator function must be compatible with "Generator[A, Any, Any]"
21+
annotations_generators.py:116:16 - error: Return type of generator function must be compatible with "Generator[A, Any, Any]"
2222
  "Generator[A, Unknown, Unknown]" is not assignable to "Iterator[B]"
2323
    Type parameter "_T_co@Iterator" is covariant, but "A" is not a subtype of "B"
2424
      "A" is not assignable to "B" (reportReturnType)
25-
annotations_generators.py:119:16 - error: Return type of generator function must be compatible with "Generator[int, Any, Any]"
25+
annotations_generators.py:117:16 - error: Return type of generator function must be compatible with "Generator[int, Any, Any]"
2626
  "Generator[int, Unknown, Unknown]" is not assignable to "Iterator[B]"
2727
    Type parameter "_T_co@Iterator" is covariant, but "int" is not a subtype of "B"
2828
      "int" is not assignable to "B" (reportReturnType)
29-
annotations_generators.py:135:16 - error: Return type of generator function must be compatible with "Generator[None, Any, Any]"
29+
annotations_generators.py:133:16 - error: Return type of generator function must be compatible with "Generator[None, Any, Any]"
3030
  "Generator[None, int, Unknown]" is not assignable to "Generator[None, str, None]"
3131
    Type parameter "_SendT_contra@Generator" is contravariant, but "int" is not a supertype of "str"
3232
      "str" is not assignable to "int" (reportReturnType)

conformance/results/pyright/callables_kwargs.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
conformant = "Partial"
2-
notes = """
3-
Allows callable without kwargs to be assigned to callable with unpacked kwargs
4-
"""
52
output = """
63
callables_kwargs.py:28:5 - error: Could not access item in TypedDict
74
  "v2" is not a required key in "TD2", so access may result in runtime exception (reportTypedDictNotRequiredAccess)
@@ -30,8 +27,10 @@ callables_kwargs.py:103:19 - error: Type "(**kwargs: **TD2) -> None" is not assi
3027
      Extra parameter "v3" (reportAssignmentType)
3128
callables_kwargs.py:111:30 - error: Typed dictionary overlaps with keyword parameter: v1 (reportGeneralTypeIssues)
3229
callables_kwargs.py:122:21 - error: Expected TypedDict type argument for Unpack (reportGeneralTypeIssues)
30+
callables_kwargs.py:134:19 - error: Type "(*, v1: int, v3: str, v2: str = "") -> None" is not assignable to declared type "TDProtocol6"
31+
  Type "(*, v1: int, v3: str, v2: str = "") -> None" is not assignable to type "(**kwargs: **TD2) -> None"
32+
    Parameter "**kwargs" has no corresponding parameter (reportAssignmentType)
3333
"""
34-
conformance_automated = "Fail"
34+
conformance_automated = "Pass"
3535
errors_diff = """
36-
Line 134: Expected 1 errors
3736
"""
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version = "pyright 1.1.393"
2-
test_duration = 1.4
1+
version = "pyright 1.1.394"
2+
test_duration = 1.3

conformance/results/pytype/annotations_generators.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,26 @@ async def generator9() -> int: # E: incompatible return type
4646
yield None # E
4747
\u001b[1m\u001b[31m~~~~~~~~~~~~~~\u001b[39m\u001b[0m
4848
49-
annotations_generators.py:100:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: Bad return type 'IntIterator' for generator function generator15 [bad-yield-annotation]
49+
annotations_generators.py:99:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: Bad return type 'IntIterator' for generator function generator15 [bad-yield-annotation]
5050
5151
def generator15() -> IntIterator: # OK
5252
\u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m
5353
yield 0
5454
\u001b[1m\u001b[31m~~~~~~~~~~~\u001b[39m\u001b[0m
5555
56-
annotations_generators.py:109:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: Bad return type 'AsyncIntIterator' for async generator function generator16 [bad-yield-annotation]
56+
annotations_generators.py:107:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: Bad return type 'AsyncIntIterator' for async generator function generator16 [bad-yield-annotation]
5757
5858
async def generator16() -> AsyncIntIterator: # OK
5959
\u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m
6060
yield 0
6161
\u001b[1m\u001b[31m~~~~~~~~~~~\u001b[39m\u001b[0m
6262
63-
annotations_generators.py:118:5: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in generator18: bad return type [bad-return-type]
63+
annotations_generators.py:116:5: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in generator18: bad return type [bad-return-type]
6464
6565
yield from generator17() # E: incompatible generator type
6666
\u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m
6767
68-
annotations_generators.py:119:5: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in generator18: bad return type [bad-return-type]
68+
annotations_generators.py:117:5: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in generator18: bad return type [bad-return-type]
6969
7070
yield from [1] # E: incompatible generator type
7171
\u001b[1m\u001b[31m~~~~~~~~~~~~~~\u001b[39m\u001b[0m
@@ -76,7 +76,7 @@ errors_diff = """
7676
Line 51: Expected 1 errors
7777
Line 87: Expected 1 errors
7878
Line 92: Expected 1 errors
79-
Line 135: Expected 1 errors
80-
Line 100: Unexpected errors ["annotations_generators.py:100:1: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: Bad return type 'IntIterator' for generator function generator15 [bad-yield-annotation]"]
81-
Line 109: Unexpected errors ["annotations_generators.py:109:1: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: Bad return type 'AsyncIntIterator' for async generator function generator16 [bad-yield-annotation]"]
79+
Line 133: Expected 1 errors
80+
Line 99: Unexpected errors ["annotations_generators.py:99:1: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: Bad return type 'IntIterator' for generator function generator15 [bad-yield-annotation]"]
81+
Line 107: Unexpected errors ["annotations_generators.py:107:1: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in <module>: Bad return type 'AsyncIntIterator' for async generator function generator16 [bad-yield-annotation]"]
8282
"""
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version = "pytype 2024.10.11"
2-
test_duration = 36.6
2+
test_duration = 34.9

conformance/results/results.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,16 @@ <h3>Python Type System Conformance Test Results</h3>
159159
<div class="table_container"><table><tbody>
160160
<tr><th class="col1">&nbsp;</th>
161161
<th class='tc-header'><div class='tc-name'>mypy 1.15.0</div>
162-
<div class='tc-time'>1.2sec</div>
162+
<div class='tc-time'>1.8sec</div>
163163
</th>
164-
<th class='tc-header'><div class='tc-name'>pyright 1.1.393</div>
165-
<div class='tc-time'>1.4sec</div>
164+
<th class='tc-header'><div class='tc-name'>pyright 1.1.394</div>
165+
<div class='tc-time'>1.3sec</div>
166166
</th>
167167
<th class='tc-header'><div class='tc-name'>pyre 0.9.23</div>
168-
<div class='tc-time'>7.8sec</div>
168+
<div class='tc-time'>6.5sec</div>
169169
</th>
170170
<th class='tc-header'><div class='tc-name'>pytype 2024.10.11</div>
171-
<div class='tc-time'>36.6sec</div>
171+
<div class='tc-time'>34.9sec</div>
172172
</th>
173173
</tr>
174174
<tr><th class="column" colspan="5">
@@ -608,7 +608,7 @@ <h3>Python Type System Conformance Test Results</h3>
608608
</tr>
609609
<tr><th class="column col1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;callables_kwargs</th>
610610
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Allows callable without kwargs to be assigned to callable with unpacked kwargs</p></span></div></th>
611-
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Allows callable without kwargs to be assigned to callable with unpacked kwargs</p></span></div></th>
611+
<th class="column col2 partially-conformant">Partial</th>
612612
<th class="column col2 conformant">Pass</th>
613613
<th class="column col2 not-conformant"><div class="hover-text">Unsupported<span class="tooltip-text" id="bottom"><p>Does not understand Unpack in the context of **kwargs annotation.</p></span></div></th>
614614
</tr>

conformance/tests/annotations_coroutines.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ async def func1(ignored: int, /) -> str:
1616
return "spam"
1717

1818

19-
assert_type(func1, Callable[[int], Coroutine[Any, Any, str]])
19+
# Don't use assert_type here because some type checkers infer
20+
# the narrower type types.CoroutineType rather than typing.Coroutine
21+
# in this case.
22+
v1: Callable[[int], Coroutine[Any, Any, str]] = func1
2023

2124

2225
async def func2() -> None:

conformance/tests/annotations_generators.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@ async def generator29() -> AsyncIterator[int]:
179179
raise NotImplementedError
180180

181181

182-
assert_type(generator29, Callable[[], Coroutine[Any, Any, AsyncIterator[int]]])
182+
# Don't use assert_type here because some type checkers infer
183+
# the narrower type types.CoroutineType rather than typing.Coroutine
184+
# in this case.
185+
v1: Callable[[], Coroutine[Any, Any, AsyncIterator[int]]] = generator29
183186

184187

185188
async def generator30() -> AsyncIterator[int]:

0 commit comments

Comments
 (0)