Skip to content

Fix argument counting to ignore commas within nested brackets/types #1019

Closed

Description

@squid-protocol

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

  1. added this to the v2.4.8 milestone on Aug 16, 2026
  2. added
    scope:frontier
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope:frontier

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions