You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Clone the https://github.com/python/typing repo.
73
-
*Create and activate a Python 3.12 virtual environment.
74
-
* Switch to the `conformance` subdirectory and install all dependencies (`pip install -r requirements.txt`).
75
-
*Switch to the `src` subdirectory and run `python main.py`.
74
+
*Install [uv](https://docs.astral.sh/uv/)and ensure Python 3.12 is available.
75
+
* Switch to the `conformance` subdirectory and install locked dependencies (`uv sync --python 3.12 --frozen`).
76
+
*Run the conformance tool (`uv run --python 3.12 --frozen python src/main.py`).
76
77
77
78
Note that some type checkers may not run on some platforms. If a type checker fails to install, tests will be skipped for that type checker.
78
79
79
80
## Reporting Conformance Results
80
81
81
82
Different type checkers report errors in different ways (with different wording in error messages and different line numbers or character ranges for errors). This variation makes it difficult to fully automate test validation given that tests will want to check for both false positive and false negative type errors. Some level of manual inspection will therefore be needed to determine whether a type checker is fully conformant with all tests in any given test file. This "scoring" process is required only when the output of a test changes — e.g. when a new version of that type checker is released and the tests are rerun. We assume that the output of a type checker will be the same from one run to the next unless/until a new version is released that fixes or introduces a bug. In this case, the output will need to be manually inspected and the conformance results re-scored for those tests whose output has changed.
82
83
83
-
Conformance results are reported and summarized for each supported type checker. Currently, results are reported for mypy, pyrefly, pyright, and zuban. It is the goal and desire to add additional type checkers over time.
84
+
[Conformance results](https://htmlpreview.github.io/?https://github.com/python/typing/blob/main/conformance/results/results.html) are reported and summarized for each supported type checker. Currently, results are reported for mypy, pyrefly, pyright, zuban and ty. It is the goal and desire to add additional type checkers over time.
84
85
85
86
## Adding a New Test Case
86
87
@@ -92,7 +93,22 @@ If a test is updated (augmented or fixed), the process is similar to when adding
92
93
93
94
## Updating a Type Checker
94
95
95
-
If a new version of a type checker is released, re-run the test tool with the new version. If the type checker output has changed for any test cases, the tool will supply the old and new outputs. Examine these to determine whether the conformance status has changed. Once the conformance status has been updated, re-run the test tool again to regenerate the summary report.
96
+
Type checker versions are locked in `uv.lock`.
97
+
98
+
To bump all supported checkers to their latest released versions:
99
+
100
+
```bash
101
+
python scripts/bump_type_checkers.py
102
+
```
103
+
104
+
After bumping, install the new lockfile and rerun conformance:
105
+
106
+
```bash
107
+
uv sync --python 3.12 --frozen
108
+
uv run --python 3.12 --frozen python src/main.py
109
+
```
110
+
111
+
If checker output changes for any test cases, examine those deltas to determine whether the conformance status has changed. Once the conformance status has been updated, rerun the tool to regenerate the summary report.
aliases_recursive.py:20: error: List item 1 has incompatible type "complex"; expected "int | str | float | list[Json] | dict[str, Json] | None" [list-item]
5
5
aliases_recursive.py:38: error: Incompatible types in assignment (expression has type "tuple[int, tuple[str, int], tuple[int, tuple[int, list[int]]]]", variable has type "RecursiveTuple") [assignment]
6
-
aliases_recursive.py:39: error: Name "t6" already defined on line 38 [no-redef]
6
+
aliases_recursive.py:39: error: Incompatible types in assignment (expression has type "tuple[int, list[int]]", variable has type "RecursiveTuple") [assignment]
7
7
aliases_recursive.py:50: error: Dict entry 0 has incompatible type "str": "list[int]"; expected "str": "str | int | Mapping[str, RecursiveMapping]" [dict-item]
8
8
aliases_recursive.py:51: error: Dict entry 2 has incompatible type "str": "list[int]"; expected "str": "str | int | Mapping[str, RecursiveMapping]" [dict-item]
9
9
aliases_recursive.py:52: error: Dict entry 2 has incompatible type "str": "list[int]"; expected "str": "str | int | Mapping[str, RecursiveMapping]" [dict-item]
callables_kwargs.py:101: error: Incompatible types in assignment (expression has type "def func1(**kwargs: Unpack[TD2]) -> None", variable has type "TDProtocol3") [assignment]
17
+
callables_kwargs.py:101: error: Incompatible types in assignment (expression has type "def func1(**kwargs: **TD2) -> None", variable has type "TDProtocol3") [assignment]
19
18
callables_kwargs.py:101: note: "TDProtocol3.__call__" has type "def __call__(self, *, v1: int, v2: int, v3: str) -> None"
20
-
callables_kwargs.py:102: error: Incompatible types in assignment (expression has type "def func1(**kwargs: Unpack[TD2]) -> None", variable has type "TDProtocol4") [assignment]
19
+
callables_kwargs.py:102: error: Incompatible types in assignment (expression has type "def func1(**kwargs: **TD2) -> None", variable has type "TDProtocol4") [assignment]
21
20
callables_kwargs.py:102: note: "TDProtocol4.__call__" has type "def __call__(self, *, v1: int) -> None"
22
-
callables_kwargs.py:103: error: Incompatible types in assignment (expression has type "def func1(**kwargs: Unpack[TD2]) -> None", variable has type "TDProtocol5") [assignment]
21
+
callables_kwargs.py:103: error: Incompatible types in assignment (expression has type "def func1(**kwargs: **TD2) -> None", variable has type "TDProtocol5") [assignment]
23
22
callables_kwargs.py:103: note: "TDProtocol5.__call__" has type "def __call__(self, v1: int, v3: str) -> None"
24
-
callables_kwargs.py:111: error: Overlap between argument names and ** TypedDict items: "v1" [misc]
25
-
callables_kwargs.py:122: error: Unpack item in ** argument must be a TypedDict [misc]
23
+
callables_kwargs.py:111: error: Overlap between parameter names and ** TypedDict items: "v1" [misc]
24
+
callables_kwargs.py:122: error: Unpack item in ** parameter must be a TypedDict [misc]
Does not honor metaclass __call__ method when evaluating constructor call.
4
4
Does not skip evaluation of __new__ and __init__ if custom metaclass call returns non-class.
@@ -7,14 +7,12 @@ conformance_automated = "Fail"
7
7
errors_diff = """
8
8
Line 26: Unexpected errors ['constructors_call_metaclass.py:26: error: Expression is of type "Class1", not "Never" [assert-type]', 'constructors_call_metaclass.py:26: error: Missing positional argument "x" in call to "Class1" [call-arg]']
9
9
Line 39: Unexpected errors ['constructors_call_metaclass.py:39: error: Expression is of type "Class2", not "int | Meta2" [assert-type]', 'constructors_call_metaclass.py:39: error: Missing positional argument "x" in call to "Class2" [call-arg]']
10
-
Line 46: Unexpected errors ['constructors_call_metaclass.py:46: error: Argument 2 for "super" not an instance of argument 1 [misc]']
11
10
"""
12
11
output = """
13
12
constructors_call_metaclass.py:26: error: Expression is of type "Class1", not "Never" [assert-type]
14
13
constructors_call_metaclass.py:26: error: Missing positional argument "x" in call to "Class1" [call-arg]
15
14
constructors_call_metaclass.py:39: error: Expression is of type "Class2", not "int | Meta2" [assert-type]
16
15
constructors_call_metaclass.py:39: error: Missing positional argument "x" in call to "Class2" [call-arg]
17
-
constructors_call_metaclass.py:46: error: Argument 2 for "super" not an instance of argument 1 [misc]
18
16
constructors_call_metaclass.py:54: error: Missing positional argument "x" in call to "Class3" [call-arg]
19
17
constructors_call_metaclass.py:68: error: Missing positional argument "x" in call to "Class4" [call-arg]
Copy file name to clipboardExpand all lines: conformance/results/mypy/constructors_callable.toml
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -17,33 +17,33 @@ Line 128: Unexpected errors ['constructors_callable.py:128: error: Expression is
17
17
Line 145: Unexpected errors ['constructors_callable.py:145: error: Expression is of type "Class6Any", not "Any" [assert-type]', 'constructors_callable.py:145: error: Too few arguments [call-arg]']
18
18
"""
19
19
output = """
20
-
constructors_callable.py:36: note: Revealed type is "def (x: builtins.int) -> constructors_callable.Class1"
20
+
constructors_callable.py:36: note: Revealed type is "def (x: int) -> constructors_callable.Class1"
21
21
constructors_callable.py:38: error: Too few arguments [call-arg]
0 commit comments