Skip to content

Commit 61b7135

Browse files
committed
Merge remote-tracking branch 'upstream/main' into tvt-match
2 parents 5841fb4 + 859d3d3 commit 61b7135

File tree

232 files changed

+3623
-377
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

232 files changed

+3623
-377
lines changed

.github/workflows/conformance.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ jobs:
3232
uv sync --python 3.12 --frozen
3333
uv run --python 3.12 --frozen python src/main.py
3434
35+
- name: Validate conformance invariants
36+
working-directory: conformance
37+
run: |
38+
uv run --python 3.12 --frozen python src/validate_results.py
39+
3540
- name: Assert conformance results are up to date
3641
run: |
3742
if [ -n "$(git status --porcelain -- conformance/results)" ]; then

conformance/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This project contains test cases for behaviors defined in the Python typing spec
1212

1313
* [concepts](https://typing.python.org/en/latest/spec/concepts.html)
1414
* [annotations](https://typing.python.org/en/latest/spec/annotations.html)
15+
* [typeforms](https://typing.python.org/en/latest/spec/type-forms.html)
1516
* [specialtypes](https://typing.python.org/en/latest/spec/special-types.html)
1617
* [generics](https://typing.python.org/en/latest/spec/generics.html)
1718
* [qualifiers](https://typing.python.org/en/latest/spec/qualifiers.html)
@@ -80,7 +81,7 @@ Note that some type checkers may not run on some platforms. If a type checker fa
8081

8182
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.
8283

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 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.
8485

8586
## Adding a New Test Case
8687

conformance/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ dependencies = [
99
"tomli",
1010
"tomlkit",
1111
"zuban",
12+
"ty",
1213
]
1314

1415
[tool.uv]

conformance/results/mypy/aliases_recursive.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ output = """
33
aliases_recursive.py:19: error: Dict entry 1 has incompatible type "str": "complex"; expected "str": "int | str | float | list[Json] | dict[str, Json] | None" [dict-item]
44
aliases_recursive.py:20: error: List item 1 has incompatible type "complex"; expected "int | str | float | list[Json] | dict[str, Json] | None" [list-item]
55
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]
77
aliases_recursive.py:50: error: Dict entry 0 has incompatible type "str": "list[int]"; expected "str": "str | int | Mapping[str, RecursiveMapping]" [dict-item]
88
aliases_recursive.py:51: error: Dict entry 2 has incompatible type "str": "list[int]"; expected "str": "str | int | Mapping[str, RecursiveMapping]" [dict-item]
99
aliases_recursive.py:52: error: Dict entry 2 has incompatible type "str": "list[int]"; expected "str": "str | int | Mapping[str, RecursiveMapping]" [dict-item]

conformance/results/mypy/constructors_call_metaclass.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
conformant = "Unupported"
1+
conformant = "Unsupported"
22
notes = """
33
Does not honor metaclass __call__ method when evaluating constructor call.
44
Does not skip evaluation of __new__ and __init__ if custom metaclass call returns non-class.

conformance/results/mypy/directives_version_platform.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ Does not understand three-element form of sys.version checks.
44
Does not understand os.name checks.
55
"""
66
output = """
7-
directives_version_platform.py:19: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]
8-
directives_version_platform.py:27: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]
9-
directives_version_platform.py:40: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]
10-
directives_version_platform.py:45: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]
7+
directives_version_platform.py:26: error: Expression is of type "int | str", not "int" [assert-type]
8+
directives_version_platform.py:33: error: Name "val3" is not defined [name-defined]
9+
directives_version_platform.py:42: error: Expression is of type "int | str", not "int" [assert-type]
10+
directives_version_platform.py:50: error: Name "val6" is not defined [name-defined]
11+
directives_version_platform.py:59: error: Name "val9" is not defined [name-defined]
1112
"""
1213
conformance_automated = "Pass"
1314
errors_diff = """

conformance/results/mypy/enums_members.toml

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,23 @@ Does not treat attributes with private names as non-members.
99
"""
1010
conformance_automated = "Fail"
1111
errors_diff = """
12-
Line 82: Expected 1 errors
13-
Line 83: Expected 1 errors
14-
Line 129: Expected 1 errors
15-
Line 27: Unexpected errors ['enums_members.py:27: error: Expression is of type "Literal[Pet.genus]", not "str" [assert-type]']
16-
Line 28: Unexpected errors ['enums_members.py:28: error: Expression is of type "Literal[Pet.species]", not "str" [assert-type]']
17-
Line 35: Unexpected errors ['enums_members.py:35: error: Expression is of type "Literal[Pet2.genus]", not "str" [assert-type]']
18-
Line 36: Unexpected errors ['enums_members.py:36: error: Expression is of type "Literal[Pet2.species]", not "str" [assert-type]']
19-
Line 100: Unexpected errors ['enums_members.py:100: error: Expression is of type "Literal[TrafficLight.AMBER]", not "Literal[TrafficLight.YELLOW]" [assert-type]']
20-
Line 117: Unexpected errors ['enums_members.py:117: error: Expression is of type "member[Callable[[Example], None]]", not "Any" [assert-type]', 'enums_members.py:117: error: Parameter 1 of Literal[...] is invalid [valid-type]']
12+
Line 86: Expected 1 errors
13+
Line 87: Expected 1 errors
14+
Line 133: Expected 1 errors
15+
Line 104: Unexpected errors ['enums_members.py:104: error: Expression is of type "Literal[TrafficLight.AMBER]", not "Literal[TrafficLight.YELLOW]" [assert-type]']
16+
Line 121: Unexpected errors ['enums_members.py:121: error: Expression is of type "member[Callable[[Example], None]]", not "Any" [assert-type]', 'enums_members.py:121: error: Parameter 1 of Literal[...] is invalid [valid-type]']
2117
"""
2218
output = """
23-
enums_members.py:27: error: Expression is of type "Literal[Pet.genus]", not "str" [assert-type]
24-
enums_members.py:28: error: Expression is of type "Literal[Pet.species]", not "str" [assert-type]
25-
enums_members.py:35: error: Expression is of type "Literal[Pet2.genus]", not "str" [assert-type]
26-
enums_members.py:36: error: Expression is of type "Literal[Pet2.species]", not "str" [assert-type]
27-
enums_members.py:50: error: Enum members must be left unannotated [misc]
28-
enums_members.py:50: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members
29-
enums_members.py:84: error: Parameter 1 of Literal[...] is invalid [valid-type]
30-
enums_members.py:85: error: Parameter 1 of Literal[...] is invalid [valid-type]
31-
enums_members.py:100: error: Expression is of type "Literal[TrafficLight.AMBER]", not "Literal[TrafficLight.YELLOW]" [assert-type]
32-
enums_members.py:116: error: Expression is of type "int", not "Literal[Example.b]" [assert-type]
33-
enums_members.py:117: error: Expression is of type "member[Callable[[Example], None]]", not "Any" [assert-type]
34-
enums_members.py:117: error: Parameter 1 of Literal[...] is invalid [valid-type]
35-
enums_members.py:128: note: Revealed type is "Any"
36-
enums_members.py:128: note: 'reveal_type' always outputs 'Any' in unchecked functions
37-
enums_members.py:146: error: Expression is of type "Literal[Pet5.DOG]", not "int" [assert-type]
38-
enums_members.py:147: error: Expression is of type "Literal[Pet5.FISH]", not "int" [assert-type]
19+
enums_members.py:54: error: Enum members must be left unannotated [misc]
20+
enums_members.py:54: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members
21+
enums_members.py:88: error: Parameter 1 of Literal[...] is invalid [valid-type]
22+
enums_members.py:89: error: Parameter 1 of Literal[...] is invalid [valid-type]
23+
enums_members.py:104: error: Expression is of type "Literal[TrafficLight.AMBER]", not "Literal[TrafficLight.YELLOW]" [assert-type]
24+
enums_members.py:120: error: Expression is of type "int", not "Literal[Example.b]" [assert-type]
25+
enums_members.py:121: error: Expression is of type "member[Callable[[Example], None]]", not "Any" [assert-type]
26+
enums_members.py:121: error: Parameter 1 of Literal[...] is invalid [valid-type]
27+
enums_members.py:132: note: Revealed type is "Any"
28+
enums_members.py:132: note: 'reveal_type' always outputs 'Any' in unchecked functions
29+
enums_members.py:150: error: Expression is of type "Literal[Pet5.DOG]", not "int" [assert-type]
30+
enums_members.py:151: error: Expression is of type "Literal[Pet5.FISH]", not "int" [assert-type]
3931
"""

conformance/results/mypy/generics_defaults.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
conformant = "Partial"
2+
notes = """
3+
Does not detect a TypeVar with a default used after a TypeVarTuple.
4+
Does not fully support defaults on TypeVarTuple and ParamSpec.
5+
"""
26
output = """
37
generics_defaults.py:24: error: "T" cannot appear after "DefaultStrT" in type parameter list because it has no default type [misc]
48
generics_defaults.py:66: error: "AllTheDefaults" expects between 2 and 5 type arguments, but 1 given [type-arg]
Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
conformant = "Partial"
2+
notes = """
3+
Does not correctly handle defaults referencing other TypeVars.
4+
"""
25
output = """
36
generics_defaults_referential.py:23: error: Expression is of type "type[slice[StartT, StopT, StepT]]", not "type[slice[int, int, int | None]]" [assert-type]
4-
generics_defaults_referential.py:37: error: Argument 1 to "Foo" has incompatible type "str"; expected "int" [arg-type]
5-
generics_defaults_referential.py:53: error: Type parameter "Start2T" has a default type that refers to one or more type variables that are out of scope [misc]
6-
generics_defaults_referential.py:74: error: TypeVar default must be one of the constraint types [misc]
7-
generics_defaults_referential.py:77: error: TypeVar default must be one of the constraint types [misc]
7+
generics_defaults_referential.py:38: error: Argument 1 to "Foo" has incompatible type "str"; expected "int" [arg-type]
8+
generics_defaults_referential.py:54: error: Type parameter "Start2T" has a default type that refers to one or more type variables that are out of scope [misc]
9+
generics_defaults_referential.py:75: error: TypeVar default must be one of the constraint types [misc]
810
generics_defaults_referential.py:78: error: TypeVar default must be one of the constraint types [misc]
9-
generics_defaults_referential.py:103: error: Expression is of type "Bar[int, list[Never]]", not "Bar[int, list[int]]" [assert-type]
11+
generics_defaults_referential.py:79: error: TypeVar default must be one of the constraint types [misc]
12+
generics_defaults_referential.py:104: error: Expression is of type "Bar[int, list[Never]]", not "Bar[int, list[int]]" [assert-type]
1013
"""
1114
conformance_automated = "Fail"
1215
errors_diff = """
13-
Line 36: Expected 1 errors
14-
Line 60: Expected 1 errors
15-
Line 68: Expected 1 errors
16+
Line 37: Expected 1 errors
17+
Line 61: Expected 1 errors
18+
Line 69: Expected 1 errors
1619
Line 23: Unexpected errors ['generics_defaults_referential.py:23: error: Expression is of type "type[slice[StartT, StopT, StepT]]", not "type[slice[int, int, int | None]]" [assert-type]']
17-
Line 77: Unexpected errors ['generics_defaults_referential.py:77: error: TypeVar default must be one of the constraint types [misc]']
18-
Line 103: Unexpected errors ['generics_defaults_referential.py:103: error: Expression is of type "Bar[int, list[Never]]", not "Bar[int, list[int]]" [assert-type]']
20+
Line 78: Unexpected errors ['generics_defaults_referential.py:78: error: TypeVar default must be one of the constraint types [misc]']
21+
Line 104: Unexpected errors ['generics_defaults_referential.py:104: error: Expression is of type "Bar[int, list[Never]]", not "Bar[int, list[int]]" [assert-type]']
1922
"""
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
conformant = "Partial"
2+
notes = """
3+
Does not correctly resolve defaults when classes are used directly.
4+
"""
25
output = """
36
generics_defaults_specialization.py:30: error: Bad number of arguments for type alias, expected between 0 and 1, given 2 [type-arg]
4-
generics_defaults_specialization.py:45: error: Expression is of type "type[Bar[DefaultStrT]]", not "type[Bar[str]]" [assert-type]
5-
generics_defaults_specialization.py:55: error: The type "type[Foo]" is not generic and not indexable [misc]
7+
generics_defaults_specialization.py:56: error: The type "type[Foo]" is not generic and not indexable [misc]
68
"""
79
conformance_automated = "Fail"
810
errors_diff = """
9-
Line 45: Unexpected errors ['generics_defaults_specialization.py:45: error: Expression is of type "type[Bar[DefaultStrT]]", not "type[Bar[str]]" [assert-type]']
11+
Line 46: Expected 1 errors
1012
"""

0 commit comments

Comments
 (0)