Small type inference fix - #40
Merged
Tobias-Kohn merged 2 commits intoJul 25, 2026
Merged
Conversation
with for-loop iteration and cross-function parameter inference Covers list[Actor]/set[Actor]/tuple[Actor, ...] declared in a .pyi stub, iterated in a for-loop, and passed into another function whose parameter type is inferred from that call site - a combination not exercised by the existing completer_pyi_generic_* tests, which only check direct indexing/unpacking.
A parameter annotation (e.g. `def foo(w: Widget)`, `def foo(items: set[Widget])`) resolved via TypeAstWalker.getType to the raw ClassType/PrimitiveType itself. Real instance members live in getInstanceFields, which only an Instance wrapper exposes - the raw type's own getFields is always empty. Every other place that produces a value of a user's type (constructor calls, function return values, for-loop targets) already wraps it in Instance; parameter annotations were the one gap, silently losing all completions for any annotated parameter. Also fills in two related gaps in annotation parsing that were masking the fix for two of the three container kinds: `set[X]` had no case at all (fell through to ANY_TYPE), and `tuple[X, ...]` (variadic) was misparsed as a fixed 2-arity tuple instead of a VarTupleType - both now mirror the handling already used for .pyi-declared types.
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.
It turns out the error I was having is on our side on Strype. In the course of investigating a couple more tests got added so I thought I may as well keep them. During the investigation a small bug was found with type annotations and with iterating over sets and tuples, so those fixes (plus tests) are submitted here.