-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[red-knot] Implicit instance attributes #15811
Merged
+657
−53
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
04e26ac
[red-knot] Implicit instance attributes
sharkdp 59d112f
Avoid allocations for names
sharkdp b2158bd
Add (passing) tests for (a, b) = … assignments in class body
sharkdp 83c3be2
Remove outdated TODO
sharkdp 84f9b6c
Turn ScopeInfo into a struct
sharkdp 8068837
Add comment explaining why we union with Unknown
sharkdp c8d0807
Make operator precedence explicit, add comment
sharkdp b12357d
Use enum instead of bool
sharkdp 4ed94c6
Use ScopeKind instead of custom BuilderScopeKind enum
sharkdp 43a3482
Add fine-grained salsa queries to avoid re-inferring types for unrela…
sharkdp f54baed
Use Name instead of &'db str
sharkdp 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 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 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 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 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 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this would be useful to have as a general query and if it should be defined next to
infer_expression_types
instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a similar thought. It could certainly be used in more places, but I wasn't sure if we want the additional query in those places? I'll note it down as a task and open a small PR after this has been merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is intuitive to me why
attribute_assignments
should be a query, but it's less intuitive to me why this should be a query. I don't see what additional dependencies are introduced here above those that the underlyinginfer_expression_types
query would have anyway. So I guess this is not about dependencies, but rather about a smaller returned value so backdating can be more effective?It feels intuitively to me that we would get more caching value with fewer cached memos if we placed the salsa query caching at the level of
Class::own_instance_member
orType::member
, rather than at such a fine-grained level that does such little work over the underlyinginfer_expression_types
. But we should of course validate any such changes with observed performance differences.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is the
expression.node_ref
. It accesses the AST node from the module where the class is declared, meaning the enclosing query has to re-run whenever the declaring module changes -- which we don't want.Doing it here is mainly about avoiding calling a query (and caching the value which is expensive) in cases where we don't need to. Although I admit, I don't have any numbers on whether caching here is a significantly lower number than caching at the
own_instance_member
level.