Repository navigation
Fix NullReferenceException in hover when a TypeVar resolves to a dict specialization - #17
Merged
Merged
Conversation
… specialization PythonDictionaryType overrides CreateInstance and dereferences the argument set directly, so the null guard added to PythonClassType in #16 never runs on this path. Hover documentation passes a null argument set down (GetReturnDocumentation -> GetSpecificReturnType(self, null) -> CreateSpecificReturnFromTypeVar -> CreateInstance(null)), which crashed hover for methods of multi-parameter generic classes whose TypeVar return resolves to a dict specialization. Mirror the null guard PythonCollectionType already has. Test infra changes needed to run the suite on modern setups: - PythonVersions now discovers CPython 3.9-3.12 (LatestAvailable3X only considered 3.5-3.8, none of which install cleanly on Apple Silicon). - UnixPythonInstallPathResolver skips broken interpreters on PATH (a stale pyenv shim crashed discovery for the whole suite). - FromOsPath hover assertions use prefix matching (newer interpreters include the scraped docstring after the signature). Tracked by LIM-43637 (GitHub issues are disabled on this fork). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
daniel-apiiro
approved these changes
Jul 22, 2026
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
Sibling of #16. That fix guarded
PythonClassType.CreateInstanceagainst the null argument set that hover documentation passes down — butPythonDictionaryTypeoverridesCreateInstanceand dereferencesargsdirectly, so the base-class guard never runs. Hovering a method of a multi-parameter generic class whose TypeVar return resolves to a dict specialization still throws:In production this surfaces as deterministic JSON-RPC
-32000hover errors and degraded class attribution (a customer environment, ~12 per extraction cycle — see LIM-43637, the tracker for this change since GitHub issues are disabled on this fork).Fix
One line: mirror the null guard
PythonCollectionType.CreateInstancealready has (args?.Arguments?.Count). Behavior with a non-null argument set is unchanged; the null path returns the sameEmptyDictionarycontents the existing non-single-argument branch uses.Survey of the remaining
CreateInstanceoverrides:PythonCollectionTypeandPythonClassTypeare guarded, theTyping*collection types ignoreargs.Typing/Values/Type.cs,Typing/Values/NamedTuple.csandTyping/Values/TypeVar.csalso dereferenceargs, but are not reachable as a resolved TypeVar target and have no observed fingerprint — left untouched.Regression test
HoverTests.GenericMethodReturningTypeVarResolvedToDict— a two-TypeVar generic whose TypeVar return resolves to a dict specialization, next to the #16 test. Verified red before the fix with the exact production stack, green after.Test infra (needed to run the suite on modern machines)
PythonVersionsnow discovers CPython 3.9–3.12;LatestAvailable3Xonly considered 3.5–3.8, none of which install cleanly on Apple Silicon. On machines with ≤3.8 only, nothing changes.UnixPythonInstallPathResolverskips broken interpreters on PATH (a stale pyenv shim used to crash discovery for the entire suite withIndexOutOfRangeException).FromOsPathhover assertions use prefix matching — newer interpreters include the scraped docstring after the signature.Testing
No CI on this fork — run locally on an arm64 Mac under Python 3.12 (same interpreter major.minor as the extractor image), built with
-p:RuntimeIdentifier= -p:PlatformTarget=AnyCPU(RuntimeIdentifierslacksosx-arm64, so a default build silently produces x64-only assemblies that the arm64 runtime cannot load).HoverTests: 16 passed, 2 skipped (need Python 2.7).Microsoft.Python.LanguageServer.Tests(excludingIndexManagerTests, which hangs on this machine on an environment issue unrelated to this change): failure set identical to master under the same environment (14 pre-existing Python-3.12 drift failures), plusFromOsPathnow passes. No new failures.Ship plan (like #16 / release 1.9): merge, tag release 1.10 from master (note: master already contains #16; the 1.9 tag was cut on the PR branch), then bump
docker/Lim.FeaturesExtractor.Unified.Dockerfilein lim from 1.9 to 1.10.