Repository navigation
Fix cls diagnostic wording and quoted type[] hover - #4723
Divyansh151005 wants to merge 1 commit into
Conversation
Reject self/cls superclass diagnostics by comparing class to class (e.g. `Child` vs `Base`) instead of mixing `type[Child]` with class `Base`. For hover, prefer type traces at string content ranges so a quoted name inside `type['Child']` resolves like an unquoted `Child` instead of the enclosing `type[...]` expression. Co-authored-by: Cursor <cursoragent@cursor.com>
|
This pull request has been imported. If you are a Meta employee, you can view this in D117995447. (Because this pull request was imported automatically, there will not be any future comments.) |
|
This pull request has been automatically marked as stale because it has not had recent activity for more than 2 weeks. If you are still working on this this pull request, please add a comment or push new commits to keep it active. Otherwise, please unassign yourself and allow someone else to take over. Thank you for your contributions! |
rchen152
left a comment
There was a problem hiding this comment.
Thanks! I'll merge this after getting a second internal review.
FYI I patched one minor issue, which is that the hover logic needs to find the part of the expression that is being hovered over rather than using the entire expression. (No action needed from you.)
stroxler
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Summary
Fixes two presentation issues from #4703:
invalid-annotationforcls/selfreceivers — compare class to class (Childis not a superclass of classBase) instead of mixing a class-object type with a class name (type[Child]… superclass of classBase).type['Child']— prefer type traces at the string content range (where rewritten forward-refNamenodes are recorded) so hover showstype[Child]like an unquotedtype[Child], nottype[type[Child]]from the enclosingtype[...]expression.Also avoids double-rendering
Type::Type(ClassDef(_))in the display layer, sinceClassDefalready prints astype[C].Fixes #4703
Test Plan