Repository navigation
fix(python): walk a class nested in a class under its outer class - #2691
Merged
Merged
Conversation
…e LSP RED on F11a alone: py_process_class walks a nested class under the module, so none of its LSP rows join the method nodes. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
py_process_class qualified every class under the module, so a class nested in a class (proj.m.Outer.Inner, the QN extraction gives it) was walked as proj.m.Inner: its methods' LSP rows carried callers no node has and never joined. A typed-parameter call in such a method got no edge at all, a self call fell to unique_name and a constructor to same_module. A nested class, decorated or not, is now walked under its enclosing class through the same py_process_class_in the function-local classes use. Tests: pipeline_python_nested_class_methods_resolve(_parallel). Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
…11a with origin/main 1346ac4) Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
The Python LSP walked a class nested in a class body (plain or decorated) as if it were declared at module
level. Its methods were walked under
proj.m.Innerwhile extraction defines them underproj.m.Outer.Inner, so:self.method(),super().method()and builtin calls inside a nested class fell back to name guesses(
suffix_match) that pick an unrelated same-named method elsewhere in the project.py_process_class_in(py_lsp.c) now walks a nested class, and a decorated nested class, under the outerclass's QN, which is the QN extraction gives it. Classes nested in functions (#1548) and top-level classes
are unchanged.
Stacked on #2690 (decorated nested classes are extracted). This PR's base branch is #2690's branch,
fix/py-decorated-nested-class; once #2690 merges, this PR's diff against main is this change alone. Noindex-format change.
Evidence
Base #2690 @4d71327c vs this change @ace384c9, 26 Python repos (manifest v1), production builds, macOS
arm64,
--repeat 2, every repeat byte-identical. The corpus delta was measured against #2690 at 4d71327,before #2679 (dotted base QNs, a different
py_lsp.cfunction) reached main. The branch has since mergedmain, and PR CI tests the merged tree. Nodes are unchanged, and so is every edge type except:
Another 250 CALLS keep their target and move from a name guess to an LSP strategy.
suffix_matchguess. Each one was replaced, on the same callline, by an LSP-resolved edge to a different target. The 173 added CALLS are all LSP-resolved
(
lsp_method112,lsp_builtin_method28,lsp_builtin_constructor15,lsp_super8, others 10).DtlsClientHello.CipherSuites,.Cookie, ...)call their own
_read, notAlpn._read.HSTORE.Comparator.contains/has_all/ ... reach the inheritedTypeEngine.Comparator.operate, notassociationproxy'soperate.FieldPanel.BoundPanel/InlinePanel.BoundPanelself.is_shown/id_for_label/js_optsreach their own methods.ReferenceModels.BaseDeadlineReference.evaluate_with'sself._evaluate_withandSerializedBaseDeadlineReference.__eq__/__hash__'sself.serialize_referencereach the class'sown methods, not a subclass override.
Config._ConfigStore.async_save'ssuper()call reacheshelpers.storage.Store.async_save. A test-localTestFlow.SubentryFlowHandlercalls its ownasync_step_*, not broadlink'sBroadlinkFlowHandler.async_step_finish.super()reaches the real base (djangoUUIDField.get_db_prep_value),list()/dict()/str()reach the builtins, andArrowStyle._Base.__call__'sself.transmutereaches_Base.transmute.celery smoke tests in nested test classes reaching
canvas.group.apply_asyncandSignature.delay.Tests
pipeline_python_nested_class_methods_resolve{,_parallel}: calls inside the methods of a class nestedin a class resolve through the LSP to the right targets, on the sequential and the parallel pipeline.
RED without the fix (
ASSERT(typed)).py_lsp_scale, lsp_resolution_probe, incremental) pass on the merged tree.