You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix argument counting to ignore commas within nested brackets/types #1019
Fix argument counting to ignore commas within nested brackets/types
Description
The current heuristic for counting function arguments in the core engine (gitgalaxy/core/detector.py) is overly naive. It approximates argument counts by simply running .count(",") on the captured function signature string.
This causes massive inflation of argument counts for modern, type-hinted codebases. If a signature contains complex generic type hints (e.g., Map<A, B>) or default literal objects (e.g., data: dict = {"x": 1, "y": 2}), every inner comma is falsely counted as an entirely new argument.
Resolution Strategy
Because the AST-less engine already possesses robust logic for tracking string depth (e.g., the _find_balanced_end logic used to find block boundaries), we can apply a similar fast stack-based sweep to the signature string.
Instead of a raw string count, the argument parser should loop through the signature string and only count a comma if the current nesting depth is exactly 0 (meaning the parser is not currently trapped inside a nested [], {}, < >, or ()).
Action Items
Replace the raw , counting logic in gitgalaxy/core/detector.py (specifically within the StructuralExtractor).
Implement a depth-aware comma counter that properly tracks open/close states for [], {}, <>, and ().
Ensure that string literals inside the signature (which may also contain commas) are properly shielded or ignored during the sweep.
Activity
Count function args by top-level comma depth, not raw comma count (#1019