Skip to content

Commit e7eb340

Browse files
committed
Add notes for the forward reference changes
1 parent d6e0e87 commit e7eb340

7 files changed

Lines changed: 56 additions & 70 deletions

File tree

conformance/results/mypy/annotations_forward_refs.toml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ conformant = "Partial"
22
notes = """
33
Does not report error for a forward reference that is not enclosed in quotes.
44
Does not report error for use of quoted type with `|` operator (runtime error).
5-
Incorrectly generates error for quoted type defined in class scope.
5+
Resolves forward references in type annotations at the point of definition instead of end-of-scope
66
"""
77
output = """
88
annotations_forward_refs.py:41: error: Invalid type comment or annotation [valid-type]
@@ -22,17 +22,16 @@ annotations_forward_refs.py:53: error: Invalid type comment or annotation [vali
2222
annotations_forward_refs.py:54: error: Invalid type comment or annotation [valid-type]
2323
annotations_forward_refs.py:55: error: Module "types" is not valid as a type [valid-type]
2424
annotations_forward_refs.py:55: note: Perhaps you meant to use a protocol matching the module structure?
25-
annotations_forward_refs.py:80: error: Name "ClassF" is not defined; did you mean "ClassA", "ClassB", or "ClassC"? [name-defined]
26-
annotations_forward_refs.py:87: error: Function "annotations_forward_refs.ClassD.int" is not valid as a type [valid-type]
27-
annotations_forward_refs.py:87: note: Perhaps you need "Callable[...]" or a callback protocol?
28-
annotations_forward_refs.py:89: error: Function "annotations_forward_refs.ClassD.int" is not valid as a type [valid-type]
29-
annotations_forward_refs.py:89: note: Perhaps you need "Callable[...]" or a callback protocol?
30-
annotations_forward_refs.py:96: error: Expression is of type int?, not "int" [assert-type]
25+
annotations_forward_refs.py:79: error: Name "ClassF" is not defined; did you mean "ClassA", "ClassB", or "ClassC"? [name-defined]
26+
annotations_forward_refs.py:88: error: Function "annotations_forward_refs.ClassD.int" is not valid as a type [valid-type]
27+
annotations_forward_refs.py:88: note: Perhaps you need "Callable[...]" or a callback protocol?
28+
annotations_forward_refs.py:90: error: Function "annotations_forward_refs.ClassD.int" is not valid as a type [valid-type]
29+
annotations_forward_refs.py:90: note: Perhaps you need "Callable[...]" or a callback protocol?
3130
"""
3231
conformance_automated = "Fail"
3332
errors_diff = """
3433
Line 24: Expected 1 errors
3534
Line 25: Expected 1 errors
36-
Line 87: Unexpected errors ['annotations_forward_refs.py:87: error: Function "annotations_forward_refs.ClassD.int" is not valid as a type [valid-type]']
37-
Line 96: Unexpected errors ['annotations_forward_refs.py:96: error: Expression is of type int?, not "int" [assert-type]']
35+
Line 81: Expected 1 errors
36+
Line 83: Expected 1 errors
3837
"""

conformance/results/pycroscope/annotations_forward_refs.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
conformant = "Partial"
22
notes = """
33
Fails to reject `"x" | int` annotations that fail at runtime.
4+
Resolves forward references in type annotations at the point of definition instead of end-of-scope
45
Rejects some valid quoted annotations.
56
"""
67
conformance_automated = "Fail"
78
errors_diff = """
89
Line 24: Expected 1 errors
910
Line 25: Expected 1 errors
11+
Line 81: Expected 1 errors
12+
Line 83: Expected 1 errors
1013
Line 14: Unexpected errors ['./annotations_forward_refs.py:14:8: Undefined name: ClassA [undefined_name]', './annotations_forward_refs.py:14:22: Undefined name: ClassA [undefined_name]', './annotations_forward_refs.py:14:42: Undefined name: ClassA [undefined_name]', './annotations_forward_refs.py:14:62: Undefined name: ClassA [undefined_name]']
1114
Line 16: Unexpected errors ['./annotations_forward_refs.py:16:16: Any[error] is not equivalent to ./annotations_forward_refs.py.ClassA']
1215
Line 17: Unexpected errors ['./annotations_forward_refs.py:17:16: list[Any[error]] is not equivalent to list[./annotations_forward_refs.py.ClassA]']
1316
Line 18: Unexpected errors ['./annotations_forward_refs.py:18:16: list[Any[error]] is not equivalent to list[./annotations_forward_refs.py.ClassA]']
1417
Line 19: Unexpected errors ['./annotations_forward_refs.py:19:16: list[int | Any[error]] is not equivalent to list[./annotations_forward_refs.py.ClassA | int]']
15-
Line 87: Unexpected errors ['./annotations_forward_refs.py:87:7: Unrecognized annotation (self: ./annotations_forward_refs.py.ClassD) -> None [invalid_annotation]']
16-
Line 96: Unexpected errors ['./annotations_forward_refs.py:96:12: Any[error] is not equivalent to int']
1718
"""
1819
output = """
1920
./annotations_forward_refs.py:14:8: Undefined name: ClassA [undefined_name]
@@ -41,8 +42,7 @@ output = """
4142
./annotations_forward_refs.py:53:0: Invalid type annotation [invalid_annotation]
4243
./annotations_forward_refs.py:54:0: Invalid type annotation [invalid_annotation]
4344
./annotations_forward_refs.py:55:9: Invalid type annotation <module 'types'> [invalid_annotation]
44-
./annotations_forward_refs.py:80:12: Undefined name: ClassF [undefined_name]
45-
./annotations_forward_refs.py:87:7: Unrecognized annotation (self: ./annotations_forward_refs.py.ClassD) -> None [invalid_annotation]
46-
./annotations_forward_refs.py:89:7: Unrecognized annotation (self: ./annotations_forward_refs.py.ClassD) -> None [invalid_annotation]
47-
./annotations_forward_refs.py:96:12: Any[error] is not equivalent to int
45+
./annotations_forward_refs.py:79:12: Undefined name: ClassF [undefined_name]
46+
./annotations_forward_refs.py:88:7: Unrecognized annotation (self: ./annotations_forward_refs.py.ClassD) -> None [invalid_annotation]
47+
./annotations_forward_refs.py:90:7: Unrecognized annotation (self: ./annotations_forward_refs.py.ClassD) -> None [invalid_annotation]
4848
"""

conformance/results/pyrefly/annotations_forward_refs.toml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
conformant = "Partial"
22
notes = """
3-
Types in quotes incorrectly refer to shadowing class member.
4-
Does not reject some type forms that require quotes.
53
"""
64
conformance_automated = "Fail"
75
errors_diff = """
8-
Line 87: Unexpected errors ['Expected a type form, got instance of `(self: Self@ClassD) -> None` [not-a-type]']
9-
Line 96: Unexpected errors ['assert_type(Unknown, int) failed [assert-type]']
6+
Line 81: Expected 1 errors
7+
Line 83: Expected 1 errors
108
"""
119
output = """
1210
ERROR annotations_forward_refs.py:23:12-18: `ClassA` is uninitialized [unbound-name]
@@ -28,8 +26,7 @@ ERROR annotations_forward_refs.py:52:11-13: Unary operation cannot be used in an
2826
ERROR annotations_forward_refs.py:53:11-21: Boolean operation cannot be used in annotations [invalid-annotation]
2927
ERROR annotations_forward_refs.py:54:11-17: F-string cannot be used in annotations [invalid-annotation]
3028
ERROR annotations_forward_refs.py:55:11-16: Expected a type form, got instance of `Module[types]` [not-a-type]
31-
ERROR annotations_forward_refs.py:80:14-20: Could not find name `ClassF` [unknown-name]
32-
ERROR annotations_forward_refs.py:87:9-12: Expected a type form, got instance of `(self: Self@ClassD) -> None` [not-a-type]
33-
ERROR annotations_forward_refs.py:89:8-11: Expected a type form, got instance of `(self: Self@ClassD) -> None` [not-a-type]
34-
ERROR annotations_forward_refs.py:96:12-27: assert_type(Unknown, int) failed [assert-type]
29+
ERROR annotations_forward_refs.py:79:14-20: Could not find name `ClassF` [unknown-name]
30+
ERROR annotations_forward_refs.py:88:8-11: Expected a type form, got instance of `(self: Self@ClassD) -> None` [not-a-type]
31+
ERROR annotations_forward_refs.py:90:9-12: Expected a type form, got instance of `(self: Self@ClassD) -> None` [not-a-type]
3532
"""

conformance/results/pyright/annotations_forward_refs.toml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
conformant = "Pass"
1+
conformant = "Partial"
2+
notes = """
3+
Resolves forward references in type annotations at the point of definition instead of end-of-scope
4+
"""
25
output = """
36
annotations_forward_refs.py:22:7 - error: "ClassA" is not defined (reportUndefinedVariable)
47
annotations_forward_refs.py:23:12 - error: "ClassA" is not defined (reportUndefinedVariable)
@@ -29,11 +32,14 @@ annotations_forward_refs.py:52:11 - error: Unary operator not allowed in type ex
2932
annotations_forward_refs.py:53:11 - error: Binary operator not allowed in type expression (reportInvalidTypeForm)
3033
annotations_forward_refs.py:54:11 - error: Type expressions cannot use format string literals (f-strings) (reportGeneralTypeIssues)
3134
annotations_forward_refs.py:55:10 - error: Module cannot be used as a type (reportGeneralTypeIssues)
32-
annotations_forward_refs.py:66:26 - error: "ClassB" is not defined (reportUndefinedVariable)
33-
annotations_forward_refs.py:80:14 - error: Type of "ClassF" could not be determined because it refers to itself (reportGeneralTypeIssues)
34-
annotations_forward_refs.py:80:14 - error: Variable not allowed in type expression (reportInvalidTypeForm)
35-
annotations_forward_refs.py:89:8 - error: Expected class but received "(self: Self@ClassD) -> None" (reportGeneralTypeIssues)
35+
annotations_forward_refs.py:65:26 - error: "ClassB" is not defined (reportUndefinedVariable)
36+
annotations_forward_refs.py:79:14 - error: Type of "ClassF" could not be determined because it refers to itself (reportGeneralTypeIssues)
37+
annotations_forward_refs.py:79:14 - error: Variable not allowed in type expression (reportInvalidTypeForm)
38+
annotations_forward_refs.py:88:8 - error: Expected class but received "(self: Self@ClassD) -> None" (reportGeneralTypeIssues)
3639
"""
37-
conformance_automated = "Pass"
40+
conformance_automated = "Fail"
3841
errors_diff = """
42+
Line 81: Expected 1 errors
43+
Line 83: Expected 1 errors
44+
Line 90: Expected 1 errors
3945
"""

conformance/results/results.html

Lines changed: 9 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

conformance/results/ty/annotations_forward_refs.toml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
conformance_automated = "Fail"
22
conformant = "Partial"
33
notes = """
4-
Resolves references in type annotations as referring to end-of-scope types (<https://discuss.python.org/t/annotation-string-references-in-class-scope-in-conformance-tests/105439>, <https://github.com/python/typing/pull/2144>)
4+
Fails to reject `str: "str"` forward references
55
"""
66
errors_diff = """
7-
Line 87: Unexpected errors ['annotations_forward_refs.py:87:9: error[invalid-type-form] Function `int` is not valid in a type expression']
8-
Line 95: Unexpected errors ['annotations_forward_refs.py:95:1: error[type-assertion-failure] Type `Divergent` does not match asserted type `str`']
9-
Line 96: Unexpected errors ['annotations_forward_refs.py:96:1: error[type-assertion-failure] Type `Unknown` does not match asserted type `int`']
7+
Line 81: Expected 1 errors
108
"""
119
output = """
1210
annotations_forward_refs.py:22:7: error[unresolved-reference] Name `ClassA` used when not defined
@@ -28,10 +26,9 @@ annotations_forward_refs.py:52:11: error[invalid-type-form] Unary operations are
2826
annotations_forward_refs.py:53:11: error[invalid-type-form] Boolean operations are not allowed in parameter annotations
2927
annotations_forward_refs.py:54:11: error[invalid-type-form] F-strings are not allowed in parameter annotations
3028
annotations_forward_refs.py:55:11: error[invalid-type-form] Module `types` is not valid in a parameter annotation
31-
annotations_forward_refs.py:66:26: error[unresolved-reference] Name `ClassB` used when not defined
32-
annotations_forward_refs.py:80:14: error[unresolved-reference] Name `ClassF` used when not defined
33-
annotations_forward_refs.py:87:9: error[invalid-type-form] Function `int` is not valid in a type expression
34-
annotations_forward_refs.py:89:8: error[invalid-type-form] Function `int` is not valid in a type expression
35-
annotations_forward_refs.py:95:1: error[type-assertion-failure] Type `Divergent` does not match asserted type `str`
36-
annotations_forward_refs.py:96:1: error[type-assertion-failure] Type `Unknown` does not match asserted type `int`
29+
annotations_forward_refs.py:65:26: error[unresolved-reference] Name `ClassB` used when not defined
30+
annotations_forward_refs.py:79:14: error[unresolved-reference] Name `ClassF` used when not defined
31+
annotations_forward_refs.py:83:9: error[invalid-type-form] Function `int` is not valid in a type expression
32+
annotations_forward_refs.py:88:8: error[invalid-type-form] Function `int` is not valid in a type expression
33+
annotations_forward_refs.py:90:9: error[invalid-type-form] Function `int` is not valid in a type expression
3734
"""
Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
conformant = "Partial"
2-
notes = """
3-
Incorrectly generates error for quoted type defined in class scope.
4-
"""
5-
conformance_automated = "Fail"
1+
conformance_automated = "Pass"
62
errors_diff = """
7-
Line 82: Unexpected errors ['annotations_forward_refs.py:82: error: Name "str" is not defined [name-defined]']
8-
Line 87: Unexpected errors ['annotations_forward_refs.py:87: error: Function "tests.annotations_forward_refs.ClassD.int" is not valid as a type [valid-type]']
9-
Line 95: Unexpected errors ['annotations_forward_refs.py:95: error: Expression is of type "Any", not "str" [misc]']
10-
Line 96: Unexpected errors ['annotations_forward_refs.py:96: error: Expression is of type "Any", not "int" [misc]']
113
"""
124
output = """
135
annotations_forward_refs.py:24: error: Forward reference unions cause runtime errors, consider wrapping the whole annotation with a string [misc]
@@ -31,12 +23,12 @@ annotations_forward_refs.py:53: error: Invalid type comment or annotation [vali
3123
annotations_forward_refs.py:54: error: Invalid type comment or annotation [valid-type]
3224
annotations_forward_refs.py:55: error: Module "types" is not valid as a type [valid-type]
3325
annotations_forward_refs.py:55: note: Perhaps you meant to use a protocol matching the module structure?
34-
annotations_forward_refs.py:80: error: Name "ClassF" is not defined [name-defined]
35-
annotations_forward_refs.py:82: error: Name "str" is not defined [name-defined]
36-
annotations_forward_refs.py:87: error: Function "tests.annotations_forward_refs.ClassD.int" is not valid as a type [valid-type]
37-
annotations_forward_refs.py:87: note: Perhaps you need "Callable[...]" or a callback protocol?
38-
annotations_forward_refs.py:89: error: Function "tests.annotations_forward_refs.ClassD.int" is not valid as a type [valid-type]
39-
annotations_forward_refs.py:89: note: Perhaps you need "Callable[...]" or a callback protocol?
40-
annotations_forward_refs.py:95: error: Expression is of type "Any", not "str" [misc]
41-
annotations_forward_refs.py:96: error: Expression is of type "Any", not "int" [misc]
26+
annotations_forward_refs.py:79: error: Name "ClassF" is not defined [name-defined]
27+
annotations_forward_refs.py:81: error: Name "str" is not defined [name-defined]
28+
annotations_forward_refs.py:83: error: Function "tests.annotations_forward_refs.ClassD.int" is not valid as a type [valid-type]
29+
annotations_forward_refs.py:83: note: Perhaps you need "Callable[...]" or a callback protocol?
30+
annotations_forward_refs.py:88: error: Function "tests.annotations_forward_refs.ClassD.int" is not valid as a type [valid-type]
31+
annotations_forward_refs.py:88: note: Perhaps you need "Callable[...]" or a callback protocol?
32+
annotations_forward_refs.py:90: error: Function "tests.annotations_forward_refs.ClassD.int" is not valid as a type [valid-type]
33+
annotations_forward_refs.py:90: note: Perhaps you need "Callable[...]" or a callback protocol?
4234
"""

0 commit comments

Comments
 (0)