diff --git a/gitnexus/src/core/ingestion/languages/python/query.ts b/gitnexus/src/core/ingestion/languages/python/query.ts index fa6e07687..bd4f73a30 100644 --- a/gitnexus/src/core/ingestion/languages/python/query.ts +++ b/gitnexus/src/core/ingestion/languages/python/query.ts @@ -185,6 +185,24 @@ export const PYTHON_SCOPE_QUERY = ` (#eq? @_enum "enumerate") (#eq? @_items "items")) @type-binding.alias +;; for i, k, v in enumerate(d.items()) — 3-var flat destructuring of +;; the (i, (k,v)) tuple emitted by enumerate over items(). Bind v +;; (last id) to d. +(for_statement + left: (pattern_list + (identifier) + (identifier) + (identifier) @type-binding.name) + right: (call + function: (identifier) @_enum + arguments: (argument_list + (call + function: (attribute + object: (identifier) @type-binding.type + attribute: (identifier) @_items)))) + (#eq? @_enum "enumerate") + (#eq? @_items "items")) @type-binding.alias + ;; for v in d.values() — bind v to d (dict-strip yields value type). (for_statement left: (identifier) @type-binding.name diff --git a/gitnexus/src/core/ingestion/languages/python/scopes.scm b/gitnexus/src/core/ingestion/languages/python/scopes.scm index 2961a0eeb..c57ccb67f 100644 --- a/gitnexus/src/core/ingestion/languages/python/scopes.scm +++ b/gitnexus/src/core/ingestion/languages/python/scopes.scm @@ -197,6 +197,22 @@ (#eq? @_enum "enumerate") (#eq? @_items "items")) @type-binding.alias +; for i, k, v in enumerate(d.items()) — 3-var flat destructuring. +(for_statement + left: (pattern_list + (identifier) + (identifier) + (identifier) @type-binding.name) + right: (call + function: (identifier) @_enum + arguments: (argument_list + (call + function: (attribute + object: (identifier) @type-binding.type + attribute: (identifier) @_items)))) + (#eq? @_enum "enumerate") + (#eq? @_items "items")) @type-binding.alias + ; for v in d.values() — bind v to d (dict-strip yields value type). (for_statement left: (identifier) @type-binding.name