Skip to content

Commit 09ee24b

Browse files
committed
Merge remote-tracking branch 'upstream/main' into typeform
2 parents 2d160fb + 22d9392 commit 09ee24b

File tree

171 files changed

+3052
-213
lines changed

Some content is hidden

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

171 files changed

+3052
-213
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Note that some type checkers may not run on some platforms. If a type checker fa
8181

8282
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.
8383

84-
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.
8585

8686
## Adding a New Test Case
8787

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/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.
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
conformant = "Partial"
1+
conformant = "Unsupported"
22
notes = """
3+
Does not synthesize `__hash__ = None` as a class attribute for unhashable dataclasses.
4+
Does not report when an unhashable dataclass has `__hash__` called directly on an instance.
35
Does not report when dataclass is not compatible with Hashable protocol.
46
"""
57
output = """
8+
dataclasses_hash.py:14: error: Expression is of type "Callable[[object], int]", not "None" [assert-type]
9+
dataclasses_hash.py:36: error: Expression is of type "Callable[[object], int]", not "None" [assert-type]
610
"""
711
conformance_automated = "Fail"
812
errors_diff = """
9-
Line 15: Expected 1 errors
10-
Line 32: Expected 1 errors
13+
Line 17: Expected 1 errors
14+
Line 18: Expected 1 errors
15+
Line 39: Expected 1 errors
16+
Line 40: Expected 1 errors
17+
Line 14: Unexpected errors ['dataclasses_hash.py:14: error: Expression is of type "Callable[[object], int]", not "None" [assert-type]']
18+
Line 36: Unexpected errors ['dataclasses_hash.py:36: error: Expression is of type "Callable[[object], int]", not "None" [assert-type]']
1119
"""

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 = """
Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,24 @@
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]
4-
generics_defaults.py:30: error: Expression is of type "type[NoNonDefaults[DefaultStrT, DefaultIntT]]", not "type[NoNonDefaults[str, int]]" [assert-type]
5-
generics_defaults.py:31: error: Expression is of type "type[NoNonDefaults[str, DefaultIntT]]", not "type[NoNonDefaults[str, int]]" [assert-type]
6-
generics_defaults.py:38: error: Expression is of type "type[OneDefault[float, DefaultBoolT]]", not "type[OneDefault[float, bool]]" [assert-type]
7-
generics_defaults.py:45: error: Expression is of type "type[AllTheDefaults[T1, T2, DefaultStrT, DefaultIntT, DefaultBoolT]]", not "type[AllTheDefaults[Any, Any, str, int, bool]]" [assert-type]
8-
generics_defaults.py:46: error: Expression is of type "type[AllTheDefaults[int, complex, DefaultStrT, DefaultIntT, DefaultBoolT]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]
9-
generics_defaults.py:50: error: Type application has too few types (expected between 2 and 5) [misc]
10-
generics_defaults.py:52: error: Expression is of type "type[AllTheDefaults[int, complex, DefaultStrT, DefaultIntT, DefaultBoolT]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]
11-
generics_defaults.py:55: error: Expression is of type "type[AllTheDefaults[int, complex, str, DefaultIntT, DefaultBoolT]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]
12-
generics_defaults.py:59: error: Expression is of type "type[AllTheDefaults[int, complex, str, int, DefaultBoolT]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]
13-
generics_defaults.py:79: error: Expression is of type "type[Class_ParamSpec[DefaultP]]", not "type[Class_ParamSpec[[str, int]]]" [assert-type]
14-
generics_defaults.py:94: error: Expression is of type "type[Class_TypeVarTuple[*DefaultTs]]", not "type[Class_TypeVarTuple[str, int]]" [assert-type]
15-
generics_defaults.py:107: error: TypeVar default must be a subtype of the bound type [misc]
16-
generics_defaults.py:114: error: TypeVar default must be one of the constraint types [misc]
17-
generics_defaults.py:132: error: Expression is of type "int", not "Any" [assert-type]
18-
generics_defaults.py:156: error: Expression is of type "type[Foo6[*tuple[Any, ...], Any]]", not "type[Foo6[int, str, [float, bool]]]" [assert-type]
19-
generics_defaults.py:156: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [misc]
20-
generics_defaults.py:157: error: Expression is of type "type[Foo6[*tuple[Any, ...], Any]]", not "type[Foo6[int, str, [bytes]]]" [assert-type]
21-
generics_defaults.py:157: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [misc]
8+
generics_defaults.py:66: error: "AllTheDefaults" expects between 2 and 5 type arguments, but 1 given [type-arg]
9+
generics_defaults.py:139: error: Expression is of type "tuple[*tuple[str, int], ...]", not "tuple[str, int]" [assert-type]
10+
generics_defaults.py:152: error: TypeVar default must be a subtype of the bound type [misc]
11+
generics_defaults.py:159: error: TypeVar default must be one of the constraint types [misc]
12+
generics_defaults.py:177: error: Expression is of type "int", not "Any" [assert-type]
13+
generics_defaults.py:203: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [valid-type]
14+
generics_defaults.py:204: error: Expression is of type "tuple[Any, ...]", not "tuple[int, str]" [assert-type]
15+
generics_defaults.py:205: error: Expression is of type "def (*Any, **Any) -> None", not "Callable[[float, bool], None]" [assert-type]
2216
"""
2317
conformance_automated = "Fail"
2418
errors_diff = """
25-
Line 143: Expected 1 errors
26-
Line 30: Unexpected errors ['generics_defaults.py:30: error: Expression is of type "type[NoNonDefaults[DefaultStrT, DefaultIntT]]", not "type[NoNonDefaults[str, int]]" [assert-type]']
27-
Line 31: Unexpected errors ['generics_defaults.py:31: error: Expression is of type "type[NoNonDefaults[str, DefaultIntT]]", not "type[NoNonDefaults[str, int]]" [assert-type]']
28-
Line 38: Unexpected errors ['generics_defaults.py:38: error: Expression is of type "type[OneDefault[float, DefaultBoolT]]", not "type[OneDefault[float, bool]]" [assert-type]']
29-
Line 45: Unexpected errors ['generics_defaults.py:45: error: Expression is of type "type[AllTheDefaults[T1, T2, DefaultStrT, DefaultIntT, DefaultBoolT]]", not "type[AllTheDefaults[Any, Any, str, int, bool]]" [assert-type]']
30-
Line 46: Unexpected errors ['generics_defaults.py:46: error: Expression is of type "type[AllTheDefaults[int, complex, DefaultStrT, DefaultIntT, DefaultBoolT]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]']
31-
Line 52: Unexpected errors ['generics_defaults.py:52: error: Expression is of type "type[AllTheDefaults[int, complex, DefaultStrT, DefaultIntT, DefaultBoolT]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]']
32-
Line 55: Unexpected errors ['generics_defaults.py:55: error: Expression is of type "type[AllTheDefaults[int, complex, str, DefaultIntT, DefaultBoolT]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]']
33-
Line 59: Unexpected errors ['generics_defaults.py:59: error: Expression is of type "type[AllTheDefaults[int, complex, str, int, DefaultBoolT]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]']
34-
Line 79: Unexpected errors ['generics_defaults.py:79: error: Expression is of type "type[Class_ParamSpec[DefaultP]]", not "type[Class_ParamSpec[[str, int]]]" [assert-type]']
35-
Line 94: Unexpected errors ['generics_defaults.py:94: error: Expression is of type "type[Class_TypeVarTuple[*DefaultTs]]", not "type[Class_TypeVarTuple[str, int]]" [assert-type]']
36-
Line 156: Unexpected errors ['generics_defaults.py:156: error: Expression is of type "type[Foo6[*tuple[Any, ...], Any]]", not "type[Foo6[int, str, [float, bool]]]" [assert-type]', 'generics_defaults.py:156: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [misc]']
37-
Line 157: Unexpected errors ['generics_defaults.py:157: error: Expression is of type "type[Foo6[*tuple[Any, ...], Any]]", not "type[Foo6[int, str, [bytes]]]" [assert-type]', 'generics_defaults.py:157: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [misc]']
19+
Line 188: Expected 1 errors
20+
Line 139: Unexpected errors ['generics_defaults.py:139: error: Expression is of type "tuple[*tuple[str, int], ...]", not "tuple[str, int]" [assert-type]']
21+
Line 203: Unexpected errors ['generics_defaults.py:203: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [valid-type]']
22+
Line 204: Unexpected errors ['generics_defaults.py:204: error: Expression is of type "tuple[Any, ...]", not "tuple[int, str]" [assert-type]']
23+
Line 205: Unexpected errors ['generics_defaults.py:205: error: Expression is of type "def (*Any, **Any) -> None", not "Callable[[float, bool], None]" [assert-type]']
3824
"""
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +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:94: error: Expression is of type "type[Bar[Z1, ListDefaultT]]", not "type[Bar[Any, list[Any]]]" [assert-type]
10-
generics_defaults_referential.py:95: error: Expression is of type "type[Bar[int, ListDefaultT]]", not "type[Bar[int, list[int]]]" [assert-type]
11-
generics_defaults_referential.py:96: 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]
1213
"""
1314
conformance_automated = "Fail"
1415
errors_diff = """
15-
Line 36: Expected 1 errors
16-
Line 60: Expected 1 errors
17-
Line 68: Expected 1 errors
16+
Line 37: Expected 1 errors
17+
Line 61: Expected 1 errors
18+
Line 69: Expected 1 errors
1819
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]']
19-
Line 77: Unexpected errors ['generics_defaults_referential.py:77: error: TypeVar default must be one of the constraint types [misc]']
20-
Line 94: Unexpected errors ['generics_defaults_referential.py:94: error: Expression is of type "type[Bar[Z1, ListDefaultT]]", not "type[Bar[Any, list[Any]]]" [assert-type]']
21-
Line 95: Unexpected errors ['generics_defaults_referential.py:95: error: Expression is of type "type[Bar[int, ListDefaultT]]", not "type[Bar[int, list[int]]]" [assert-type]']
22-
Line 96: Unexpected errors ['generics_defaults_referential.py:96: 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]']
2322
"""

conformance/results/mypy/generics_defaults_specialization.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
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]
47
generics_defaults_specialization.py:45: error: Expression is of type "type[Bar[DefaultStrT]]", not "type[Bar[str]]" [assert-type]

conformance/results/pyrefly/dataclasses_hash.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ conformance_automated = "Pass"
33
errors_diff = """
44
"""
55
output = """
6-
ERROR dataclasses_hash.py:15:16-22: `DC1` is not assignable to `Hashable` [bad-assignment]
7-
ERROR dataclasses_hash.py:32:16-22: `DC3` is not assignable to `Hashable` [bad-assignment]
6+
ERROR dataclasses_hash.py:17:1-16: Expected a callable, got `None` [not-callable]
7+
ERROR dataclasses_hash.py:18:16-22: `DC1` is not assignable to `Hashable` [bad-assignment]
8+
ERROR dataclasses_hash.py:39:1-16: Expected a callable, got `None` [not-callable]
9+
ERROR dataclasses_hash.py:40:16-22: `DC3` is not assignable to `Hashable` [bad-assignment]
810
"""

0 commit comments

Comments
 (0)