-
Notifications
You must be signed in to change notification settings - Fork 302
Change the typing spec around string references #2144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
7627175
Change the typing spec around string references
davidhalter d08c226
Improve the wording around string references in the spec
davidhalter 070312d
Remove error types
davidhalter 41fc20c
Update docs/spec/annotations.rst
davidhalter ea921e8
Merge remote-tracking branch 'origin/main' into string-annotations
davidhalter caa71f6
Wrap the test in a consistent way
davidhalter 0f56cb9
Small wording change
davidhalter cc4cec2
Ensure that forward annotations don't depend on the position in the s…
davidhalter 928464d
Merge remote-tracking branch 'origin/main' into string-annotations
davidhalter d6e0e87
Merge remote-tracking branch 'origin/main' into string-annotations
davidhalter 927aa61
Add notes for the forward reference changes
davidhalter 0f3a654
Update conformance/tests/annotations_forward_refs.py
davidhalter a687acd
Update conformance/tests/annotations_forward_refs.py
davidhalter 0d117ce
Update conformance/tests/annotations_forward_refs.py
davidhalter 813eaca
Merge remote-tracking branch 'origin/main' into string-annotations
davidhalter 6788f7d
Upgrade results
davidhalter 982907b
Add more cases for forward references
davidhalter 0742fae
Run the latest results
davidhalter 09a4088
Add notes for Zuban
davidhalter d4f53a0
Try to be more precise with forward reference notes
davidhalter 63bd33a
Add spec definition for: from __future__ import annotations
davidhalter 9b8862e
Update conformance/results/mypy/annotations_forward_refs.toml
davidhalter 09b59c9
Add forward references
davidhalter 18c5636
Latest changes from review
davidhalter fedc0e2
Test from __future__ annotations name resolution
davidhalter 1771841
Integrate the review
davidhalter 0595623
Add more tests
davidhalter 781b99f
Change notes slightly
davidhalter 9b007e0
Run main.py
davidhalter f8d079e
Merge remote-tracking branch 'origin' into string-annotations
davidhalter fdb0e1c
Address forward reference review nits
carljm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| conformant = "Partial" | ||
| notes = """ | ||
| Resolves some forward references in type annotations in classes at the point of definition instead of end-of-scope | ||
| """ | ||
| conformance_automated = "Fail" | ||
| errors_diff = """ | ||
| Line 37: Expected 1 errors | ||
| Line 39: Expected 1 errors | ||
| """ | ||
| output = """ | ||
| annotations_future_import.py:44: error: Function "annotations_future_import.ClassB.int" is not valid as a type [valid-type] | ||
| annotations_future_import.py:44: note: Perhaps you need "Callable[...]" or a callback protocol? | ||
| annotations_future_import.py:46: error: Function "annotations_future_import.ClassB.int" is not valid as a type [valid-type] | ||
| annotations_future_import.py:46: note: Perhaps you need "Callable[...]" or a callback protocol? | ||
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
conformance/results/pycroscope/annotations_future_import.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| conformant = "Partial" | ||
| notes = """ | ||
| Forward references to nested classes are not resolved | ||
| Nested classes are resolved, but its type is Any | ||
| Resolves some class annotations to outer names instead of shadowing class bindings | ||
| """ | ||
| conformance_automated = "Fail" | ||
| errors_diff = """ | ||
| Line 37: Expected 1 errors | ||
| Line 39: Expected 1 errors | ||
| Line 26: Unexpected errors ['./annotations_future_import.py:26:12: Undefined name: ClassInner [undefined_name]'] | ||
| Line 27: Unexpected errors ['./annotations_future_import.py:27:12: Undefined name: ClassInner [undefined_name]'] | ||
| Line 55: Unexpected errors ['./annotations_future_import.py:55:16: Any[inference] is not equivalent to annotations_future_import.ClassB.ClassInner'] | ||
| Line 56: Unexpected errors ['./annotations_future_import.py:56:16: Any[inference] is not equivalent to annotations_future_import.ClassB.ClassInner'] | ||
| Line 57: Unexpected errors ['./annotations_future_import.py:57:16: Any[inference] is not equivalent to annotations_future_import.ClassB.ClassInner'] | ||
| Line 58: Unexpected errors ['./annotations_future_import.py:58:16: Any[inference] is not equivalent to annotations_future_import.ClassB.ClassInner'] | ||
| """ | ||
| output = """ | ||
| ./annotations_future_import.py:26:12: Undefined name: ClassInner [undefined_name] | ||
| ./annotations_future_import.py:27:12: Undefined name: ClassInner [undefined_name] | ||
| ./annotations_future_import.py:44:7: Invalid type annotation <function ClassB.int at 0x...> [invalid_annotation] | ||
| ./annotations_future_import.py:46:7: Invalid type annotation <function ClassB.int at 0x...> [invalid_annotation] | ||
| ./annotations_future_import.py:55:16: Any[inference] is not equivalent to annotations_future_import.ClassB.ClassInner | ||
| ./annotations_future_import.py:56:16: Any[inference] is not equivalent to annotations_future_import.ClassB.ClassInner | ||
| ./annotations_future_import.py:57:16: Any[inference] is not equivalent to annotations_future_import.ClassB.ClassInner | ||
| ./annotations_future_import.py:58:16: Any[inference] is not equivalent to annotations_future_import.ClassB.ClassInner | ||
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
conformance/results/pyrefly/annotations_future_import.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| conformant = "Partial" | ||
| notes = """ | ||
| Forward references to nested classes are not resolved | ||
| Resolves forward references in type annotations in classes at the point of definition instead of end-of-scope | ||
| """ | ||
| conformance_automated = "Fail" | ||
| errors_diff = """ | ||
| Line 37: Expected 1 errors | ||
| Line 39: Expected 1 errors | ||
| Line 26: Unexpected errors ['Could not find name `ClassInner` [unknown-name]'] | ||
| Line 27: Unexpected errors ['Could not find name `ClassInner` [unknown-name]'] | ||
| Line 55: Unexpected errors ['assert_type(Unknown, ClassB.ClassInner) failed [assert-type]'] | ||
| Line 56: Unexpected errors ['assert_type(Unknown, ClassB.ClassInner) failed [assert-type]'] | ||
| """ | ||
| output = """ | ||
| ERROR annotations_future_import.py:26:13-23: Could not find name `ClassInner` [unknown-name] | ||
| ERROR annotations_future_import.py:27:14-24: Could not find name `ClassInner` [unknown-name] | ||
| ERROR annotations_future_import.py:44:8-11: Expected a type form, got instance of `(self: Self@ClassB) -> None` [not-a-type] | ||
| ERROR annotations_future_import.py:46:9-12: Expected a type form, got instance of `(self: Self@ClassB) -> None` [not-a-type] | ||
| ERROR annotations_future_import.py:55:16-45: assert_type(Unknown, ClassB.ClassInner) failed [assert-type] | ||
| ERROR annotations_future_import.py:56:16-45: assert_type(Unknown, ClassB.ClassInner) failed [assert-type] | ||
| """ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
conformance/results/pyright/annotations_future_import.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| conformant = "Partial" | ||
| notes = """ | ||
| Prefers to resolve forward references in classes outside of the class instead of end-of-scope | ||
| """ | ||
| conformance_automated = "Fail" | ||
| errors_diff = """ | ||
| Line 37: Expected 1 errors | ||
| Line 39: Expected 1 errors | ||
| Line 44: Expected 1 errors | ||
| Line 46: Expected 1 errors | ||
| """ | ||
| output = """ | ||
| """ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.