You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e7eb340
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: conformance/results/mypy/annotations_forward_refs.toml
+8-9Lines changed: 8 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@ conformant = "Partial"
2
2
notes = """
3
3
Does not report error for a forward reference that is not enclosed in quotes.
4
4
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
6
6
"""
7
7
output = """
8
8
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
22
22
annotations_forward_refs.py:54: error: Invalid type comment or annotation [valid-type]
23
23
annotations_forward_refs.py:55: error: Module "types" is not valid as a type [valid-type]
24
24
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?
31
30
"""
32
31
conformance_automated = "Fail"
33
32
errors_diff = """
34
33
Line 24: Expected 1 errors
35
34
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]']
Line 16: Unexpected errors ['./annotations_forward_refs.py:16:16: Any[error] is not equivalent to ./annotations_forward_refs.py.ClassA']
12
15
Line 17: Unexpected errors ['./annotations_forward_refs.py:17:16: list[Any[error]] is not equivalent to list[./annotations_forward_refs.py.ClassA]']
13
16
Line 18: Unexpected errors ['./annotations_forward_refs.py:18:16: list[Any[error]] is not equivalent to list[./annotations_forward_refs.py.ClassA]']
14
17
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]']
Copy file name to clipboardExpand all lines: conformance/results/ty/annotations_forward_refs.toml
+7-10Lines changed: 7 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,10 @@
1
1
conformance_automated = "Fail"
2
2
conformant = "Partial"
3
3
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
5
5
"""
6
6
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
10
8
"""
11
9
output = """
12
10
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
28
26
annotations_forward_refs.py:53:11: error[invalid-type-form] Boolean operations are not allowed in parameter annotations
29
27
annotations_forward_refs.py:54:11: error[invalid-type-form] F-strings are not allowed in parameter annotations
30
28
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
Incorrectly generates error for quoted type defined in class scope.
4
-
"""
5
-
conformance_automated = "Fail"
1
+
conformance_automated = "Pass"
6
2
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]']
11
3
"""
12
4
output = """
13
5
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
31
23
annotations_forward_refs.py:54: error: Invalid type comment or annotation [valid-type]
32
24
annotations_forward_refs.py:55: error: Module "types" is not valid as a type [valid-type]
33
25
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?
0 commit comments