Repository navigation
fix(python): a parameterized base links its class, like class Leaf(Base[str]) - #2998
Draft
JosefAschauer wants to merge 1 commit into
Draft
JosefAschauer wants to merge 1 commit into
JosefAschauer wants to merge 1 commit into
Conversation
…se[str]) The base-list reader took only bare identifiers and attributes, so a subscripted base (`Base[str]`, `models.Base[int]`) produced no `extends` reference and the class had no supertype edge. Both arms (wasm TreeSitterExtractor and the kernel's python.rs) now name the subscript's value. Generic[T] and other bases outside the project stay unresolved, as their plain forms do. The resolver's own text reader of a class's base list (pythonBases, used by module-global and self. dispatch) split `Pair[str, int]` at its inner comma and looked up `Base[str]` verbatim; it now drops bracketed type arguments first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018hJjBUPFiLSFBssshFwHzq
This was referenced Oct 29, 2026
This branch has not been deployed
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.
Problem
A Python class with a parameterized base,
class Leaf(Base[str]), has noextendsedge. The grammar parsesBase[str]in the base list as asubscript, and the base-list reader only took bare identifiers and attributes, so the base was skipped. Everything that follows the class hierarchy misses such a class. This is the Python counterpart of #2856 (Java/TSStore<String>), and the "generic bases" item left open in #2076.The resolver also reads a class's base list as text (
pythonBasesinname-matcher.ts, behind module-global andself.dispatch). It looked upBase[str]verbatim and splitPair[str, int]at its inner comma, socurrent = Leaf()thencurrent.run()did not reachBase.run.Fix
subscriptbase is unwrapped to itsvaluefield before the existingidentifier | attributecheck, insrc/extraction/tree-sitter.tsand in the kernel'scodegraph-kernel/src/python.rs. The reference sits at the value's start, the position the plain form had.pythonBasesdrops bracketed type arguments (nested ones too) before splitting the list.Generic[T]/Protocol[T](outside the project, like their plain forms), a computed base likemake()[0], a subscript of a subscript likeBase[int][str], and keyword arguments likemetaclass=Meta.Validation
New
__tests__/python-generic-bases.test.ts, run on both arms: wasm (CODEGRAPH_KERNEL=0) and kernel (CODEGRAPH_KERNEL_LANGS=python; skipped when no kernel is staged). 16 tests:Base[str],Base[list[int]],Pair[str, dict[str, int]], a base written over several lines, a mixed list(Mixin, Base[str]), andmodels.Base[int]all link like their plain forms;Base[int][str]link nothing;Generic[T]links nothing;Leaf/TworesolvesruntoBase::run/Pair::run, with a same-named decoy class in the file.Each fix was mutation-checked on its own: disabling the wasm unwrap fails only wasm tests, disabling the kernel unwrap fails only kernel tests, and disabling the
pythonBaseschange fails the module-global test on both arms.npx tsc --noEmit: clean. Kernel built withnpm run build:kernel.Full suite on Linux with the kernel staged: 9281 passed, 4 failed. The failures are environmental and also fail on
main:bundle-launcher×2: nozipbinary.cli-sync×2: the host runs Node 26, which prints the unsupported-Node banner.Together with feat(resolution): link Python base methods to their overrides (python-override) #2076,
Base.rungets its override link toLeaf.runon both arms.Follow-ups
pythonBasesreads only theclassline, so a base list written over several lines is invisible to it (plain bases too). Fixed in fix(python): a base list wrapped over several lines is read whole #3001, which is stacked on this PR.declaredSupertypes' Python branch counts type arguments (str,User) as supertypes, soRepo.save()onclass Repo(Base[User])reachedUser.save. Fixed in fix(python): a base's type argument is no supertype, so Repo.save() is not User.save #3000, which is independent.Independent of #2076.
🤖 Generated with Claude Code
https://claude.ai/code/session_018hJjBUPFiLSFBssshFwHzq