Skip to content

Commit 111aece

Browse files
authored
don't assert type on invalid type expressions (#2111)
1 parent 9f6d8ce commit 111aece

14 files changed

+32
-47
lines changed

conformance/results/mypy/enums_members.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ enums_members.py:35: error: Expression is of type "Literal[Pet2.genus]", not "st
2626
enums_members.py:36: error: Expression is of type "Literal[Pet2.species]", not "str" [assert-type]
2727
enums_members.py:50: error: Enum members must be left unannotated [misc]
2828
enums_members.py:50: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members
29-
enums_members.py:84: error: Expression is of type "Callable[[Pet4], str]", not "Any" [assert-type]
3029
enums_members.py:84: error: Parameter 1 of Literal[...] is invalid [valid-type]
31-
enums_members.py:85: error: Expression is of type "Callable[[Pet4], None]", not "Any" [assert-type]
3230
enums_members.py:85: error: Parameter 1 of Literal[...] is invalid [valid-type]
3331
enums_members.py:100: error: Expression is of type "Literal[TrafficLight.AMBER]", not "Literal[TrafficLight.YELLOW]" [assert-type]
3432
enums_members.py:116: error: Expression is of type "int", not "Literal[Example.b]" [assert-type]

conformance/results/pyrefly/enums_members.toml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,10 @@ Line 100: Unexpected errors ['assert_type(Literal[TrafficLight.AMBER], Literal[T
88
"""
99
output = """
1010
ERROR enums_members.py:50:5-8: Enum member `DOG` may not be annotated directly. Instead, annotate the `_value_` attribute. [invalid-annotation]
11-
ERROR enums_members.py:82:12-53: assert_type((x: Any) -> str, Any) failed [assert-type]
12-
ERROR enums_members.py:82:37-51: `Pet4.converter` is not a valid enum member [invalid-literal]
13-
ERROR enums_members.py:83:12-53: assert_type((x: int) -> int, Any) failed [assert-type]
14-
ERROR enums_members.py:83:37-51: `Pet4.transform` is not a valid enum member [invalid-literal]
15-
ERROR enums_members.py:84:12-49: assert_type((self: Pet4) -> str, Any) failed [assert-type]
16-
ERROR enums_members.py:84:35-47: `Pet4.species` is not a valid enum member [invalid-literal]
17-
ERROR enums_members.py:85:12-45: assert_type((self: Pet4) -> None, Any) failed [assert-type]
18-
ERROR enums_members.py:85:33-43: `Pet4.speak` is not a valid enum member [invalid-literal]
11+
ERROR enums_members.py:82:20-34: `Pet4.converter` is not a valid enum member [invalid-literal]
12+
ERROR enums_members.py:83:20-34: `Pet4.transform` is not a valid enum member [invalid-literal]
13+
ERROR enums_members.py:84:18-30: `Pet4.species` is not a valid enum member [invalid-literal]
14+
ERROR enums_members.py:85:16-26: `Pet4.speak` is not a valid enum member [invalid-literal]
1915
ERROR enums_members.py:100:12-62: assert_type(Literal[TrafficLight.AMBER], Literal[TrafficLight.YELLOW]) failed [assert-type]
2016
ERROR enums_members.py:116:12-43: assert_type(nonmember[int], Any) failed [assert-type]
2117
ERROR enums_members.py:116:32-41: `Example.b` is not a valid enum member [invalid-literal]

conformance/results/pyrefly/overloads_evaluation.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ conformance_automated = "Pass"
22
errors_diff = """
33
"""
44
output = """
5-
ERROR overloads_evaluation.py:38:11-13: No matching overload found for function `example1_1` [no-matching-overload]
6-
ERROR overloads_evaluation.py:46:11-17: No matching overload found for function `example1_1` [no-matching-overload]
7-
ERROR overloads_evaluation.py:51:11-14: No matching overload found for function `example1_1` [no-matching-overload]
8-
ERROR overloads_evaluation.py:115:13-22: No matching overload found for function `example2` [no-matching-overload]
5+
ERROR overloads_evaluation.py:38:11-13: No matching overload found for function `example1_1` called with arguments: () [no-matching-overload]
6+
ERROR overloads_evaluation.py:46:11-17: No matching overload found for function `example1_1` called with arguments: (Literal[1], Literal[1]) [no-matching-overload]
7+
ERROR overloads_evaluation.py:51:11-14: No matching overload found for function `example1_1` called with arguments: (Literal[1]) [no-matching-overload]
8+
ERROR overloads_evaluation.py:115:13-22: No matching overload found for function `example2` called with arguments: (int | str, int | str, Literal[1]) [no-matching-overload]
99
"""

conformance/results/pyrefly/protocols_explicit.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ conformance_automated = "Fail"
77
errors_diff = """
88
Line 27: Expected 1 errors
99
Line 89: Expected 1 errors
10-
Line 134: Expected 1 errors
1110
"""
1211
output = """
1312
ERROR protocols_explicit.py:56:20-36: `tuple[int, int, str]` is not assignable to attribute `rgb` with type `tuple[int, int, int]` [bad-assignment]
14-
ERROR protocols_explicit.py:60:10-20: Cannot instantiate `Point` because the following members are abstract: `intensity` [bad-instantiation]
13+
ERROR protocols_explicit.py:60:10-20: Cannot instantiate `Point` because the following members are abstract: `intensity`, `transparency` [bad-instantiation]
14+
ERROR protocols_explicit.py:134:15-17: Cannot instantiate `Concrete5` because the following members are abstract: `method1` [bad-instantiation]
1515
ERROR protocols_explicit.py:164:17-19: Cannot instantiate `Concrete7A` because the following members are abstract: `method1` [bad-instantiation]
1616
"""

conformance/results/pyrefly/typeddicts_readonly_inheritance.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ Does not restrictions around overriding for ReadOnly fields
44
"""
55
conformance_automated = "Fail"
66
errors_diff = """
7-
Line 98: Expected 1 errors
8-
Line 106: Expected 1 errors
97
Line 119: Expected 1 errors
10-
Line 132: Expected 1 errors
118
"""
129
output = """
1310
ERROR typeddicts_readonly_inheritance.py:36:4-10: Key `name` in TypedDict `Album2` is read-only [read-only]
@@ -16,5 +13,8 @@ ERROR typeddicts_readonly_inheritance.py:65:19-21: Missing required key `name` f
1613
ERROR typeddicts_readonly_inheritance.py:82:14-15: `Literal[3]` is not assignable to TypedDict key `ident` with type `str` [bad-typed-dict-key]
1714
ERROR typeddicts_readonly_inheritance.py:83:15-16: `Literal[3]` is not assignable to TypedDict key `ident` with type `str` [bad-typed-dict-key]
1815
ERROR typeddicts_readonly_inheritance.py:84:5-7: Missing required key `ident` for TypedDict `User` [bad-typed-dict-key]
19-
ERROR typeddicts_readonly_inheritance.py:94:5-6: Class member `F3.a` overrides parent class `F1` in an inconsistent manner [bad-override]
16+
ERROR typeddicts_readonly_inheritance.py:94:5-6: TypedDict field `a` in `F3` cannot be marked read-only; parent TypedDict `F1` defines it as mutable [bad-typed-dict-key]
17+
ERROR typeddicts_readonly_inheritance.py:98:5-6: TypedDict field `a` in `F4` must remain required because parent TypedDict `F1` defines it as required [bad-typed-dict-key]
18+
ERROR typeddicts_readonly_inheritance.py:106:5-6: TypedDict field `c` in `F6` cannot be made non-required; parent TypedDict `F1` defines it as required [bad-typed-dict-key]
19+
ERROR typeddicts_readonly_inheritance.py:132:7-11: TypedDict field `x` in `TD_B` cannot be made non-required; parent TypedDict `TD_B2` defines it as required [bad-typed-dict-key]
2020
"""

conformance/results/pyrefly/typeddicts_readonly_update.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ conformance_automated = "Pass"
33
errors_diff = """
44
"""
55
output = """
6-
ERROR typeddicts_readonly_update.py:23:10-14: No matching overload found for function `A.update` [no-matching-overload]
6+
ERROR typeddicts_readonly_update.py:23:10-14: No matching overload found for function `A.update` called with arguments: (TypedDict[A]) [no-matching-overload]
77
"""
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = "pyrefly 0.38.1"
1+
version = "pyrefly 0.39.4"

conformance/results/pyright/enums_members.toml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@ errors_diff = """
77
"""
88
output = """
99
enums_members.py:50:5 - error: Type annotations are not allowed for enum members (reportGeneralTypeIssues)
10-
enums_members.py:82:13 - error: "assert_type" mismatch: expected "Unknown" but received "(x: Unknown) -> str" (reportAssertTypeFailure)
11-
enums_members.py:82:37 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm)
12-
enums_members.py:82:42 - error: Variable not allowed in type expression (reportInvalidTypeForm)
13-
enums_members.py:83:13 - error: "assert_type" mismatch: expected "Unknown" but received "(x: int) -> int" (reportAssertTypeFailure)
14-
enums_members.py:83:37 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm)
15-
enums_members.py:83:42 - error: Variable not allowed in type expression (reportInvalidTypeForm)
16-
enums_members.py:84:13 - error: "assert_type" mismatch: expected "Unknown" but received "property" (reportAssertTypeFailure)
17-
enums_members.py:84:35 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm)
18-
enums_members.py:85:13 - error: "assert_type" mismatch: expected "Unknown" but received "(self: Pet4) -> None" (reportAssertTypeFailure)
19-
enums_members.py:85:33 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm)
10+
enums_members.py:82:20 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm)
11+
enums_members.py:82:25 - error: Variable not allowed in type expression (reportInvalidTypeForm)
12+
enums_members.py:83:20 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm)
13+
enums_members.py:83:25 - error: Variable not allowed in type expression (reportInvalidTypeForm)
14+
enums_members.py:84:18 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm)
15+
enums_members.py:85:16 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm)
2016
enums_members.py:116:13 - error: "assert_type" mismatch: expected "Unknown" but received "int" (reportAssertTypeFailure)
2117
enums_members.py:116:32 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm)
2218
enums_members.py:128:21 - information: Type of "Example2.__B" is "Literal[2]"

conformance/results/pyright/namedtuples_define_functional.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@ namedtuples_define_functional.py:52:31 - error: Names within a named tuple must
1616
namedtuples_define_functional.py:53:33 - error: Field names cannot be a keyword (reportGeneralTypeIssues)
1717
namedtuples_define_functional.py:54:33 - error: Field names cannot be a keyword (reportGeneralTypeIssues)
1818
namedtuples_define_functional.py:55:33 - error: Named tuple field names cannot start with an underscore (reportGeneralTypeIssues)
19-
namedtuples_define_functional.py:59:33 - error: Named tuple field names cannot start with an underscore (reportGeneralTypeIssues)
20-
namedtuples_define_functional.py:60:13 - error: No parameter named "_1" (reportCallIssue)
2119
namedtuples_define_functional.py:69:1 - error: Argument missing for parameter "a" (reportCallIssue)
2220
"""
23-
conformance_automated = "Fail"
21+
conformance_automated = "Pass"
2422
errors_diff = """
25-
Line 59: Unexpected errors ['namedtuples_define_functional.py:59:33 - error: Named tuple field names cannot start with an underscore (reportGeneralTypeIssues)']
26-
Line 60: Unexpected errors ['namedtuples_define_functional.py:60:13 - error: No parameter named "_1" (reportCallIssue)']
2723
"""
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = "pyright 1.1.406"
1+
version = "pyright 1.1.407"

0 commit comments

Comments
 (0)