-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fine-grained: Fix AST merge issues #4652
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
Conversation
Also process overloaded and non-overloaded functions more consistently in AST merge.
They can appear in UnboundType instances.
Not sure yet if this actually fixes any user-visible issues.
There were two issues: * The `info` attribute of the corresponding `ClassDef` wasn't updated. * `FuncDef` objects within the related `TypeInfo` weren't processed, since they are only accessible through a symbol table. Functions in normal classes are accessible by traversing the AST, in contrast.
This could at least leak memory. Not sure if this could cause invalid type checking results.
The type map could contain stale references to AST nodes.
Not sure if this is necessary but it might be.
The relevant nodes won't be exposed externally.
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.
Looks great!
What is the one remaining failure?
mypy/types.py
Outdated
[arg, ...] in Callable[[arg, ...], ret]. This is not a real type | ||
but a syntactic AST construct. | ||
but a syntactic AST construct. UnboundTypes can also have TypeList | ||
types before they are processed into Callable type.s |
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.
Typo
@@ -1503,6 +1503,11 @@ def visit_type_type(self, t: TypeType) -> T: | |||
def visit_forwardref_type(self, t: ForwardRef) -> T: | |||
raise RuntimeError('Internal error: unresolved forward reference') | |||
|
|||
def visit_type_list(self, t: TypeList) -> T: |
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.
Can other sorts of "synthetic" types show up in our traversal?
Would it be a better approach in the future to make the merger a synthetic type traverser?
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.
Hmm looks like we could be hitting other such types as well. Maybe making it a "synthetic type visitor" is the right thing to do. I'll consider making a follow-up PR about this.
On the other hand, we should perhaps only have one sort of type visitor. I don't really see the benefit of having two sorts of visitors.
The remaining failure is |
* master: New files shouldn't trigger a coarse-grained rebuild in fg cache mode (python#4669) Bump version to 0.580-dev Update revision history for 0.570 (python#4662) Fine-grained: Fix crashes when refreshing synthetic types (python#4667) Fine-grained: Support NewType and reset subtype caches (python#4656) Fine-grained: Detect changes in additional TypeInfo attributes (python#4659) Fine-grained: Apply semantic analyzer patch callbacks (python#4658) Optimize fine-grained update by using Graph as the cache (python#4622) Cleanup check_reverse_op_method (python#4017) Fine-grained: Fix AST merge issues (python#4652) Optionally check that we don't have duplicate nodes after AST merge (python#4647)
This fixes all but one AST merge checker test failures. The remaining one (testFineGrainedCallable) seems tricky to fix so I'll leave it for later. I decided not to add tests for things that can be caught using the merge checker. We'll have to run the merge checker periodically since it's not enabled by default in the test suite.
This fixes all but one AST merge checker test failures. The remaining
one seems tricky to fix so I'll leave it for later.
I decided not to add tests for things that can be caught using the
merge checker. We'll have to run the merge checker periodically
since it's not enabled by default in the test suite.