Repository navigation
fix dunder slots definition #4344 - #5627
asukaminato0721 wants to merge 16 commits into
Conversation
|
✅ This PR meets all requirements from our pull request checklist. Optional recommendations:
Note: this comment updates automatically after changes to the PR. Updates may take up to half an hour. |
|
This pull request has been imported. If you are a Meta employee, you can view this in D131487080. (Because this pull request was imported automatically, there will not be any future comments.) |
This comment has been minimized.
This comment has been minimized.
kinto0
left a comment
There was a problem hiding this comment.
Thanks for the thorough tests (all assignment forms, nested/local classes, unrelated strings). Requesting changes for the same structural reason as the feedback on #5587/#5588: the slots entry is recognized by matching AST shapes in the LSP, instead of going through the semantic information the checker already has. Details inline. These comments cover only the __slots__ commits; the __all__ commits are reviewed on #5587, #5588, and #5625.
Also, mypy_primer shows the same +10/-17 home-assistant core diff as #5588, which looks like primer noise. Please rerun it.
Use the existing definition lookup to read the exported symbol type. Keep string literal types for strings outside __all__.
Read the current checked module’s final export answer so buffers, stubs, and unopened dependencies supply the correct type.
Resolve __all__ entries only after identifier lookup fails. Cover go-to-type-definition and remove unrelated hover changes.
Resolve each entry to its definition before adding its string content range. Respect import aliases so references to independent names remain separate.
Preserve local alias identity and retain export occurrences in the normal reference index so unopened modules need no navigation queries.
Keep string content ranges from export extraction and resolve navigation and references through the checked binding. Preserve interface documentation without changing symbol identity.
Use string content ranges to preserve quotes and prefixes. Keep local source definitions during reference operations so rename updates both source files and their stubs. Validate the target before offering rename.
Read the owning class and literal slot name from the existing AST nodes. Use attribute definition lookup to navigate to the field declaration.
Resolve slot names against a generic instance of their owning class. This displays the field type while preserving its type parameters.
d52e3df to
cbb8633
Compare
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Summary
Fixes part of #4344
add support for slots definition and hover (folded from #5628).
This PR supports references from a slots entry to attribute uses. Reverse references from an attribute to slots entries are completed in #5629.
stack on #5625
Test Plan
add test