PEP 673: forbid Self in type aliases. #2194
Merged
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.
Thanks to Eric Traut who tested all the code examples in Pyright and
raised implementation concerns about
Selftype in aliases.I ran into implementation issues in Pyre too. This is because Pyre
preprocesses things like
Selfin an early phase and does aliasresolution in a later phase. Mixing the two would lead to a lot of
hacks.
@JelleZijlstra I believe you had some concerns about using
Tuplethis way at runtime. Do we need to include them too?@Gobot1234 What do you think? Do you have any workarounds or strong objections?
Here is our prior discussion about aliases on the Google Doc. A user had brought up a concern there too that
Selfoutside a class would be confusing. Given that Eric pushed back too, I feel we can drop this.Copy-pasting the discussion for easy reference: