Skip to content

Support collections module (especially Counter) #181

@dmontagu

Description

@dmontagu

I've seen Claude Code use collections.Counter when generating inline Python in a way similar to code mode. Here's the full command it generated:

Bash(gh api repos/pydantic/pydantic-ai/actions/runs -X GET --paginate --jq '
        [.workflow_runs[] | select(.name == "CI" and .event == "pull_request" and .created_at > "2026-01-17") | {
          id: .id,
          created: .created_at[:10],
          status: .conclusion,
          head_branch: .head_branch,
          actor: .actor.login
        }]' 2>/dev/null | python3 -c "
      import json, sys
      data = []
      for line in sys.stdin:
          data.extend(json.loads(line))
      print(f'Total PR CI runs in last 30 days: {len(data)}')
      from collections import Counter
      actors = Counter(d['actor'] for d in data)
      print('By actor:')
      for actor, count in actors.most_common(20):
          print(f'  {actor}: {count}')
      dates = Counter(d['created'][:10] for d in data)
      print(f'Unique days with CI runs: {len(dates)}')
      print(f'Avg runs/day: {len(data)/max(len(dates),1):.1f}')
      ")

I'm not sure how hard it would be to implement, but it might be nice to support collections.Counter (and presumably easily vibe-coded/tested), and there may be other types in collections worth supporting too (e.g., defaultdict, deque, etc.).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions