Skip to content

Python: suggest ignores class methods — only proposes top-level functions #27

Description

@Connorrmcd6

Context

First real dogfood of Surface v0.2.0 against a Python codebase — a typed Python SDK ([nansen-python-sdk]) whose public API is almost entirely methods on classes (sync/async resource methods, pagination methods, etc.).

What happened

surf suggest 'src/nansen/**/*.py' over the whole source tree proposed exactly one anchor:

# 1 unanchored public function(s). ...
  - claim: TODO the invariant calculate_retry_delay guarantees, in prose
    at: src/nansen/_utils/_retry.py > calculate_retry_delay

That's the only module-level def in the entire tree. Cross-checked:

$ grep -rcE '^def [a-zA-Z]'  src/nansen   # top-level public functions
1
$ grep -rE '^    (async )?def [a-z]' src/nansen | grep -vE 'def _' | wc -l
93                                          # public methods on classes

So suggest covered 1 of 94 public callables (~1%). The 93 public methods — the actual API surface — were silently ignored.

Why it matters

On Python (and any method-oriented language), suggest is the on-ramp for adoption: "scan my code, tell me what's uncovered." If it only ever proposes free functions, a typed-class codebase gets a near-empty suggestion and the tool looks like it found nothing to anchor. Anchoring methods works fine once written by hand — surf lint happily resolves Foo > bar, AsyncFoo > bar, dunders, properties — so this is purely a suggest enumeration gap, not a resolver gap.

Suggested fix

Have suggest walk into class bodies and propose public methods as File > Class > method anchors (respecting the existing leading-underscore = private convention, and de-duping sync/async mirrors however you prefer). Optionally a flag to include/exclude methods if free-functions-only is ever the intended default.

Repro

surf init
surf suggest 'src/**/*.py'   # against any class-heavy Python project

Environment: surf 0.2.0 (aarch64-apple-darwin), macOS.

[nansen-python-sdk]: internal Nansen Python SDK

Metadata

Metadata

Assignees

No one assigned

    Labels

    dxDeveloper experience / CLI ergonomicsenhancementNew feature or requestlanguageNew grammar / language support

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions