Skip to content

Commit 246ccdd

Browse files
Merge branch 'main' into literal-inference
2 parents 0739b10 + d08f800 commit 246ccdd

File tree

151 files changed

+2630
-60
lines changed

Some content is hidden

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

151 files changed

+2630
-60
lines changed

conformance/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Note that some type checkers may not run on some platforms. If a type checker fa
8080

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

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.
83+
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.
8484

8585
## Adding a New Test Case
8686

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/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/pyrefly/directives_version_platform.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ conformance_automated = "Pass"
33
errors_diff = """
44
"""
55
output = """
6-
ERROR directives_version_platform.py:40:17-19: `Literal['']` is not assignable to `int` [bad-assignment]
7-
ERROR directives_version_platform.py:45:17-19: `Literal['']` is not assignable to `int` [bad-assignment]
6+
ERROR directives_version_platform.py:33:19-23: Could not find name `val3` [unknown-name]
7+
ERROR directives_version_platform.py:50:19-23: Could not find name `val6` [unknown-name]
8+
ERROR directives_version_platform.py:59:19-23: Could not find name `val9` [unknown-name]
9+
ERROR directives_version_platform.py:66:19-24: `val10` may be uninitialized [unbound-name]
10+
ERROR directives_version_platform.py:67:22-27: `val11` may be uninitialized [unbound-name]
11+
ERROR directives_version_platform.py:74:22-27: `val12` may be uninitialized [unbound-name]
12+
ERROR directives_version_platform.py:75:19-24: `val13` may be uninitialized [unbound-name]
813
"""

conformance/results/pyright/directives_version_platform.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
conformant = "Pass"
22
output = """
3+
directives_version_platform.py:33:19 - error: "val3" is not defined (reportUndefinedVariable)
4+
directives_version_platform.py:50:19 - error: "val6" is not defined (reportUndefinedVariable)
5+
directives_version_platform.py:59:19 - error: "val9" is not defined (reportUndefinedVariable)
6+
directives_version_platform.py:66:19 - error: "val10" is not defined (reportUndefinedVariable)
7+
directives_version_platform.py:75:19 - error: "val13" is not defined (reportUndefinedVariable)
38
"""
49
conformance_automated = "Pass"
510
errors_diff = """

conformance/results/results.html

Lines changed: 161 additions & 20 deletions
Large diffs are not rendered by default.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
conformance_automated = "Fail"
2+
conformant = "Partial"
3+
notes = "`Concatenate` in type aliases is currently unsupported"
4+
errors_diff = """
5+
Line 87: Expected 1 errors
6+
Line 100: Expected 1 errors
7+
Line 57: Unexpected errors ['aliases_explicit.py:57:5: error[type-assertion-failure] Type `Unknown` does not match asserted type `(int, str, str, /) -> None`']
8+
"""
9+
output = """
10+
aliases_explicit.py:57:5: error[type-assertion-failure] Type `Unknown` does not match asserted type `(int, str, str, /) -> None`
11+
aliases_explicit.py:67:9: error[not-subscriptable] Cannot subscript non-generic type `<types.UnionType special-form 'int | None'>`
12+
aliases_explicit.py:68:9: error[not-subscriptable] Cannot subscript non-generic type `<class 'list[int | None]'>`
13+
aliases_explicit.py:69:29: error[invalid-type-arguments] Too many type arguments: expected 1, got 2
14+
aliases_explicit.py:70:29: error[invalid-type-arguments] Too many type arguments: expected 1, got 2
15+
aliases_explicit.py:71:24: error[invalid-type-arguments] Type argument for `ParamSpec` must be either a list of types, `ParamSpec`, `Concatenate`, or `...`
16+
aliases_explicit.py:79:1: error[invalid-type-form] Invalid right-hand side for `typing.TypeAlias` assignment
17+
aliases_explicit.py:80:1: error[invalid-type-form] Invalid right-hand side for `typing.TypeAlias` assignment
18+
aliases_explicit.py:81:1: error[invalid-type-form] Invalid right-hand side for `typing.TypeAlias` assignment
19+
aliases_explicit.py:82:1: error[invalid-type-form] Invalid right-hand side for `typing.TypeAlias` assignment
20+
aliases_explicit.py:83:1: error[invalid-type-form] Invalid right-hand side for `typing.TypeAlias` assignment
21+
aliases_explicit.py:84:1: error[invalid-type-form] Invalid right-hand side for `typing.TypeAlias` assignment
22+
aliases_explicit.py:85:1: error[invalid-type-form] Invalid right-hand side for `typing.TypeAlias` assignment
23+
aliases_explicit.py:86:1: error[invalid-type-form] Invalid right-hand side for `typing.TypeAlias` assignment
24+
aliases_explicit.py:88:1: error[invalid-type-form] Invalid right-hand side for `typing.TypeAlias` assignment
25+
aliases_explicit.py:89:1: error[invalid-type-form] Invalid right-hand side for `typing.TypeAlias` assignment
26+
aliases_explicit.py:90:1: error[invalid-type-form] Invalid right-hand side for `typing.TypeAlias` assignment
27+
aliases_explicit.py:91:1: error[invalid-type-form] Invalid right-hand side for `typing.TypeAlias` assignment
28+
aliases_explicit.py:101:6: error[call-non-callable] Object of type `UnionType` is not callable
29+
aliases_explicit.py:102:5: error[not-subscriptable] Cannot subscript non-generic type `<types.UnionType special-form 'list[Unknown] | set[Unknown]'>`
30+
"""
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
conformance_automated = "Fail"
2+
conformant = "Partial"
3+
notes = """
4+
Does not reject variables with `Any` or `Unknown` types when used as implicit type aliases.
5+
Does not support `Concatenate` in type aliases.
6+
"""
7+
errors_diff = """
8+
Line 106: Expected 1 errors
9+
Line 111: Expected 1 errors
10+
Line 112: Expected 1 errors
11+
Line 113: Expected 1 errors
12+
Line 117: Expected 1 errors
13+
Line 68: Unexpected errors ['aliases_implicit.py:68:5: error[type-assertion-failure] Type `Unknown` does not match asserted type `(int, str, str, /) -> None`']
14+
"""
15+
output = """
16+
aliases_implicit.py:68:5: error[type-assertion-failure] Type `Unknown` does not match asserted type `(int, str, str, /) -> None`
17+
aliases_implicit.py:76:9: error[not-subscriptable] Cannot subscript non-generic type `<types.UnionType special-form 'int | None'>`
18+
aliases_implicit.py:77:9: error[not-subscriptable] Cannot subscript non-generic type `<class 'list[int | None]'>`
19+
aliases_implicit.py:78:29: error[invalid-type-arguments] Too many type arguments: expected 1, got 2
20+
aliases_implicit.py:79:29: error[invalid-type-arguments] Too many type arguments: expected 1, got 2
21+
aliases_implicit.py:80:24: error[invalid-type-arguments] Type argument for `ParamSpec` must be either a list of types, `ParamSpec`, `Concatenate`, or `...`
22+
aliases_implicit.py:81:25: error[invalid-type-arguments] Type `str` is not assignable to upper bound `int | float` of type variable `TFloat@GoodTypeAlias12`
23+
aliases_implicit.py:107:9: error[invalid-type-form] Variable of type `list[<class 'int'> | <class 'str'>]` is not allowed in a type expression
24+
aliases_implicit.py:108:9: error[invalid-type-form] Variable of type `tuple[tuple[<class 'int'>, <class 'str'>]]` is not allowed in a type expression
25+
aliases_implicit.py:109:9: error[invalid-type-form] Variable of type `list[<class 'int'>]` is not allowed in a type expression
26+
aliases_implicit.py:110:9: error[invalid-type-form] Variable of type `dict[str, str]` is not allowed in a type expression
27+
aliases_implicit.py:114:9: error[invalid-type-form] Variable of type `Literal[3]` is not allowed in a type expression
28+
aliases_implicit.py:115:10: error[invalid-type-form] Variable of type `Literal[True]` is not allowed in a type expression
29+
aliases_implicit.py:116:10: error[invalid-type-form] Variable of type `Literal[1]` is not allowed in a type expression
30+
aliases_implicit.py:118:10: error[invalid-type-form] Variable of type `Literal["int"]` is not allowed in a type expression
31+
aliases_implicit.py:119:10: error[invalid-type-form] Variable of type `Literal["int | str"]` is not allowed in a type expression
32+
aliases_implicit.py:133:6: error[call-non-callable] Object of type `UnionType` is not callable
33+
aliases_implicit.py:135:5: error[not-subscriptable] Cannot subscript non-generic type `<types.UnionType special-form 'list[Unknown] | set[Unknown]'>`
34+
"""
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
conformance_automated = "Pass"
2+
errors_diff = """
3+
"""
4+
output = """
5+
aliases_newtype.py:11:8: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `Literal["user"]`
6+
aliases_newtype.py:12:14: error[invalid-assignment] Object of type `Literal[42]` is not assignable to `UserId`
7+
aliases_newtype.py:18:11: error[invalid-assignment] Object of type `<NewType pseudo-class 'UserId'>` is not assignable to `type`
8+
aliases_newtype.py:23:16: error[invalid-argument-type] Argument to function `isinstance` is incorrect: Expected `type | UnionType | tuple[Divergent, ...]`, found `<NewType pseudo-class 'UserId'>`
9+
aliases_newtype.py:26:21: error[invalid-base] Cannot subclass an instance of NewType
10+
aliases_newtype.py:35:1: error[invalid-newtype] The name of a `NewType` (`BadName`) must match the name of the variable it is assigned to (`GoodName`)
11+
aliases_newtype.py:41:6: error[invalid-type-form] `GoodNewType1` is a `NewType` and cannot be specialized
12+
aliases_newtype.py:47:38: error[invalid-newtype] invalid base for `typing.NewType`: type `int | str`
13+
aliases_newtype.py:50:38: error[invalid-newtype] invalid base for `typing.NewType`: A `NewType` base cannot be generic
14+
aliases_newtype.py:52:38: error[invalid-newtype] invalid base for `typing.NewType`: type `Hashable`
15+
aliases_newtype.py:54:38: error[invalid-newtype] invalid base for `typing.NewType`: type `Literal[7]`
16+
aliases_newtype.py:61:38: error[invalid-newtype] invalid base for `typing.NewType`: type `TD1`
17+
aliases_newtype.py:63:15: error[invalid-newtype] Wrong number of arguments in `NewType` creation: expected 2, found 3
18+
aliases_newtype.py:65:38: error[invalid-newtype] invalid base for `typing.NewType`: type `Any`
19+
"""
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
conformance_automated = "Fail"
2+
conformant = "Unsupported"
3+
errors_diff = """
4+
Line 19: Expected 1 errors
5+
Line 20: Expected 1 errors
6+
Line 38: Expected 1 errors
7+
Line 39: Expected 1 errors
8+
Line 50: Expected 1 errors
9+
Line 51: Expected 1 errors
10+
Line 52: Expected 1 errors
11+
Line 63: Expected 1 errors
12+
Line 69: Expected 1 errors
13+
Line 72: Expected 1 errors
14+
Line 75: Expected 1 errors
15+
"""
16+
output = """
17+
"""

0 commit comments

Comments
 (0)