Generic type parsing for type annotations (v0.9.0) - #92
Merged
Conversation
- Create parse_type_annotation() helper for parsing AST type nodes - Handles simple types (str, int, CustomClass) - Handles generic types (list[int], dict[str, Any]) - Handles union types (str | None, int | str) - Handles Optional types (Optional[str]) - Handles nested generics (list[dict[str, int]]) - Add 18 comprehensive unit tests covering all type patterns - All 310 unit tests passing
- Replace _get_type_string() implementation with type_utils helper - Now extracts list[T], dict[K, V], Optional[T], X | None types - Add comprehensive test for generic type extraction - All 311 unit tests passing
- Replace _get_type_string() implementation with type_utils helper - Now handles list[T], dict[K, V], Optional[T], X | None in annotations - Add test verifying generic type inference works correctly - All 312 unit tests passing (20 new tests total)
ydkadri
approved these changes
May 1, 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.
Summary
Adds full support for generic type annotations in Python code, eliminating false positive warnings from type inference.
Closes #39
Changes
New functionality:
list[T],dict[K, V],set[T],tuple[T, ...]generic typesX | None,int | str | NoneOptional[T]from typing modulelist[dict[str, int]],dict[str, list[int]]List[int],Dict[str, Any]Implementation:
type_utils.parse_type_annotation()shared helper functionASTExtractor._get_type_string()to use helper for extracting parameter and return type annotationsTypeInferrer._get_type_string()to use helper for type inference validationImpact:
list[int]→ stored as "list"list[int]→ stored as "list[int]"Testing
parse_type_annotation()helperCommits
🤖 Generated with Claude Code