Skip to content

Commit 0105dc2

Browse files
Conformance tests: Fix manual scoring discrepancy for pyre (#1770)
Pyre infers "Literal[1]" instead of "int", which seems legal. Change the test to get an int from a function parameter instead, so that all type checkers are aligned. Part of #1692.
1 parent 7cbb3f2 commit 0105dc2

10 files changed

+39
-40
lines changed

Diff for: conformance/results/mypy/generics_paramspec_semantics.toml

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ generics_paramspec_semantics.py:26: error: Unexpected keyword argument "a" [cal
44
generics_paramspec_semantics.py:26: error: Unexpected keyword argument "b" [call-arg]
55
generics_paramspec_semantics.py:27: error: Argument 2 has incompatible type "str"; expected "bool" [arg-type]
66
generics_paramspec_semantics.py:61: error: Argument 2 to "func1" has incompatible type "Callable[[NamedArg(int, 'y')], int]"; expected "Callable[[NamedArg(int, 'x')], int]" [arg-type]
7-
generics_paramspec_semantics.py:97: error: Argument 1 has incompatible type "int"; expected "str" [arg-type]
8-
generics_paramspec_semantics.py:107: error: Argument 1 has incompatible type "int"; expected "bool" [arg-type]
9-
generics_paramspec_semantics.py:119: error: Argument 1 has incompatible type "int"; expected "str" [arg-type]
10-
generics_paramspec_semantics.py:126: error: Argument 1 to "expects_int_first" has incompatible type "Callable[[str], int]"; expected "Callable[[int], int]" [arg-type]
11-
generics_paramspec_semantics.py:126: note: This is likely because "one" has named arguments: "x". Consider marking them positional-only
12-
generics_paramspec_semantics.py:131: error: Argument 1 to "expects_int_first" has incompatible type "Callable[[NamedArg(int, 'x')], int]"; expected "Callable[[int, NamedArg(int, 'x')], int]" [arg-type]
13-
generics_paramspec_semantics.py:136: error: Argument 1 to "expects_int_first" has incompatible type "Callable[[KwArg(int)], int]"; expected "Callable[[int, KwArg(int)], int]" [arg-type]
7+
generics_paramspec_semantics.py:98: error: Argument 1 has incompatible type "int"; expected "str" [arg-type]
8+
generics_paramspec_semantics.py:108: error: Argument 1 has incompatible type "int"; expected "bool" [arg-type]
9+
generics_paramspec_semantics.py:120: error: Argument 1 has incompatible type "int"; expected "str" [arg-type]
10+
generics_paramspec_semantics.py:127: error: Argument 1 to "expects_int_first" has incompatible type "Callable[[str], int]"; expected "Callable[[int], int]" [arg-type]
11+
generics_paramspec_semantics.py:127: note: This is likely because "one" has named arguments: "x". Consider marking them positional-only
12+
generics_paramspec_semantics.py:132: error: Argument 1 to "expects_int_first" has incompatible type "Callable[[NamedArg(int, 'x')], int]"; expected "Callable[[int, NamedArg(int, 'x')], int]" [arg-type]
13+
generics_paramspec_semantics.py:137: error: Argument 1 to "expects_int_first" has incompatible type "Callable[[KwArg(int)], int]"; expected "Callable[[int, KwArg(int)], int]" [arg-type]
1414
"""
1515
conformance_automated = "Pass"
1616
errors_diff = """

Diff for: conformance/results/mypy/version.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version = "mypy 1.10.0"
2-
test_duration = 1.5
2+
test_duration = 1.1

Diff for: conformance/results/pyre/generics_paramspec_semantics.toml

+7-9
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ generics_paramspec_semantics.py:26:0 Unexpected keyword [28]: Unexpected keyword
44
generics_paramspec_semantics.py:27:8 Incompatible parameter type [6]: In anonymous call, for 2nd positional argument, expected `bool` but got `str`.
55
generics_paramspec_semantics.py:46:16 Incompatible parameter type [6]: In call `func1`, for 2nd positional argument, expected `typing.Callable[generics_paramspec_semantics.P, int]` but got `typing.Callable(y_x)[[Named(y, int), Named(x, str)], int]`.
66
generics_paramspec_semantics.py:61:22 Incompatible parameter type [6]: In call `func1`, for 2nd positional argument, expected `typing.Callable[generics_paramspec_semantics.P, int]` but got `typing.Callable(keyword_only_y)[[KeywordOnly(y, int)], int]`.
7-
generics_paramspec_semantics.py:81:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Y[int, [int]]` but got `Y[typing_extensions.Literal[1], [int]]`.
8-
generics_paramspec_semantics.py:97:3 Incompatible parameter type [6]: In anonymous call, for 1st positional argument, expected `str` but got `int`.
9-
generics_paramspec_semantics.py:107:3 Incompatible parameter type [6]: In anonymous call, for 1st positional argument, expected `bool` but got `int`.
10-
generics_paramspec_semantics.py:119:3 Incompatible parameter type [6]: In anonymous call, for 1st positional argument, expected `str` but got `int`.
11-
generics_paramspec_semantics.py:126:1 Invalid decoration [56]: Pyre doesn't yet support decorators with ParamSpec applied to generic functions Please add # pyre-ignore[56] to `generics_paramspec_semantics.expects_int_first`.
12-
generics_paramspec_semantics.py:131:1 Invalid decoration [56]: Pyre doesn't yet support decorators with ParamSpec applied to generic functions Please add # pyre-ignore[56] to `generics_paramspec_semantics.expects_int_first`.
13-
generics_paramspec_semantics.py:136:1 Invalid decoration [56]: Pyre doesn't yet support decorators with ParamSpec applied to generic functions Please add # pyre-ignore[56] to `generics_paramspec_semantics.expects_int_first`.
7+
generics_paramspec_semantics.py:98:3 Incompatible parameter type [6]: In anonymous call, for 1st positional argument, expected `str` but got `int`.
8+
generics_paramspec_semantics.py:108:3 Incompatible parameter type [6]: In anonymous call, for 1st positional argument, expected `bool` but got `int`.
9+
generics_paramspec_semantics.py:120:3 Incompatible parameter type [6]: In anonymous call, for 1st positional argument, expected `str` but got `int`.
10+
generics_paramspec_semantics.py:127:1 Invalid decoration [56]: Pyre doesn't yet support decorators with ParamSpec applied to generic functions Please add # pyre-ignore[56] to `generics_paramspec_semantics.expects_int_first`.
11+
generics_paramspec_semantics.py:132:1 Invalid decoration [56]: Pyre doesn't yet support decorators with ParamSpec applied to generic functions Please add # pyre-ignore[56] to `generics_paramspec_semantics.expects_int_first`.
12+
generics_paramspec_semantics.py:137:1 Invalid decoration [56]: Pyre doesn't yet support decorators with ParamSpec applied to generic functions Please add # pyre-ignore[56] to `generics_paramspec_semantics.expects_int_first`.
1413
"""
15-
conformance_automated = "Fail"
14+
conformance_automated = "Pass"
1615
errors_diff = """
17-
Line 81: Unexpected errors ['generics_paramspec_semantics.py:81:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Y[int, [int]]` but got `Y[typing_extensions.Literal[1], [int]]`.']
1816
"""

Diff for: conformance/results/pyre/version.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version = "pyre 0.9.21"
2-
test_duration = 3.6
2+
test_duration = 1.7

Diff for: conformance/results/pyright/generics_paramspec_semantics.toml

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ generics_paramspec_semantics.py:61:23 - error: Argument of type "(*, y: int) ->
1414
  Type "(*, y: int) -> int" is incompatible with type "(*, x: int) -> int"
1515
    Extra parameter "y"
1616
    Missing keyword parameter "x" (reportArgumentType)
17-
generics_paramspec_semantics.py:97:4 - error: Argument of type "Literal[1]" cannot be assigned to parameter of type "str"
17+
generics_paramspec_semantics.py:98:4 - error: Argument of type "Literal[1]" cannot be assigned to parameter of type "str"
1818
  "Literal[1]" is incompatible with "str" (reportArgumentType)
19-
generics_paramspec_semantics.py:107:4 - error: Argument of type "Literal[1]" cannot be assigned to parameter "args" of type "bool"
19+
generics_paramspec_semantics.py:108:4 - error: Argument of type "Literal[1]" cannot be assigned to parameter "args" of type "bool"
2020
  "Literal[1]" is incompatible with "bool" (reportArgumentType)
21-
generics_paramspec_semantics.py:119:4 - error: Argument of type "Literal[1]" cannot be assigned to parameter of type "str"
21+
generics_paramspec_semantics.py:120:4 - error: Argument of type "Literal[1]" cannot be assigned to parameter of type "str"
2222
  "Literal[1]" is incompatible with "str" (reportArgumentType)
23-
generics_paramspec_semantics.py:126:2 - error: Argument of type "(x: str) -> int" cannot be assigned to parameter "x" of type "(int, **P@expects_int_first) -> int" in function "expects_int_first"
23+
generics_paramspec_semantics.py:127:2 - error: Argument of type "(x: str) -> int" cannot be assigned to parameter "x" of type "(int, **P@expects_int_first) -> int" in function "expects_int_first"
2424
  Type "(x: str) -> int" is incompatible with type "(int, **P@expects_int_first) -> int"
2525
    Parameter 1: type "int" is incompatible with type "str"
2626
      "int" is incompatible with "str" (reportArgumentType)
27-
generics_paramspec_semantics.py:131:2 - error: Argument of type "(*, x: int) -> int" cannot be assigned to parameter "x" of type "(int, **P@expects_int_first) -> int" in function "expects_int_first"
27+
generics_paramspec_semantics.py:132:2 - error: Argument of type "(*, x: int) -> int" cannot be assigned to parameter "x" of type "(int, **P@expects_int_first) -> int" in function "expects_int_first"
2828
  Type "(*, x: int) -> int" is incompatible with type "(int, **P@expects_int_first) -> int"
2929
    Function accepts too many positional parameters; expected 0 but received 1 (reportArgumentType)
30-
generics_paramspec_semantics.py:136:2 - error: Argument of type "(**kwargs: int) -> int" cannot be assigned to parameter "x" of type "(int, **P@expects_int_first) -> int" in function "expects_int_first"
30+
generics_paramspec_semantics.py:137:2 - error: Argument of type "(**kwargs: int) -> int" cannot be assigned to parameter "x" of type "(int, **P@expects_int_first) -> int" in function "expects_int_first"
3131
  Type "(**kwargs: int) -> int" is incompatible with type "(int, **P@expects_int_first) -> int"
3232
    Function accepts too many positional parameters; expected 0 but received 1 (reportArgumentType)
3333
"""

Diff for: conformance/results/pyright/version.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version = "pyright 1.1.366"
2-
test_duration = 1.4
2+
test_duration = 1.3

Diff for: conformance/results/pytype/generics_paramspec_semantics.toml

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ errors_diff = """
1010
Line 26: Expected 1 errors
1111
Line 27: Expected 1 errors
1212
Line 61: Expected 1 errors
13-
Line 97: Expected 1 errors
14-
Line 107: Expected 1 errors
15-
Line 119: Expected 1 errors
16-
Line 126: Expected 1 errors
17-
Line 131: Expected 1 errors
18-
Line 136: Expected 1 errors
13+
Line 98: Expected 1 errors
14+
Line 108: Expected 1 errors
15+
Line 120: Expected 1 errors
16+
Line 127: Expected 1 errors
17+
Line 132: Expected 1 errors
18+
Line 137: Expected 1 errors
1919
"""

Diff for: conformance/results/pytype/version.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version = "pytype 2024.04.11"
2-
test_duration = 32.9
2+
test_duration = 27.9

Diff for: conformance/results/results.html

+4-4
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.10.0</div>
162-
<div class='tc-time'>1.5sec</div>
162+
<div class='tc-time'>1.1sec</div>
163163
</th>
164164
<th class='tc-header'><div class='tc-name'>pyright 1.1.366</div>
165-
<div class='tc-time'>1.4sec</div>
165+
<div class='tc-time'>1.3sec</div>
166166
</th>
167167
<th class='tc-header'><div class='tc-name'>pyre 0.9.21</div>
168-
<div class='tc-time'>3.6sec</div>
168+
<div class='tc-time'>1.7sec</div>
169169
</th>
170170
<th class='tc-header'><div class='tc-name'>pytype 2024.04.11</div>
171-
<div class='tc-time'>32.9sec</div>
171+
<div class='tc-time'>27.9sec</div>
172172
</th>
173173
</tr>
174174
<tr><th class="column" colspan="5">

Diff for: conformance/tests/generics_paramspec_semantics.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ def callback_a(q: int, /) -> str:
7777
...
7878

7979

80-
y1 = Y(callback_a, 1)
81-
assert_type(y1, Y[int, [int]])
82-
y2 = y1.f
83-
assert_type(y2, Callable[[int], str])
80+
def func(x: int) -> None:
81+
y1 = Y(callback_a, x)
82+
assert_type(y1, Y[int, [int]])
83+
y2 = y1.f
84+
assert_type(y2, Callable[[int], str])
8485

8586

8687
def bar(x: int, *args: bool) -> int:

0 commit comments

Comments
 (0)