Skip to content

Docstring rework for _resolve_wildcards, distilled into a CLAUDE.md guide - #135

Open
nick-gorman wants to merge 2 commits into
translate-network-to-buses-linksfrom
docstring-guide-generic-helpers
Open

Docstring rework for _resolve_wildcards, distilled into a CLAUDE.md guide#135
nick-gorman wants to merge 2 commits into
translate-network-to-buses-linksfrom
docstring-guide-generic-helpers

Conversation

@nick-gorman

@nick-gorman nick-gorman commented Aug 11, 2026

Copy link
Copy Markdown
Member

Follows up Ellie's review feedback on #126 that the _resolve_wildcards docstring was confusing. This PR rewords that docstring, and since the rewording surfaced lessons that seemed transferable, captures them as a new CLAUDE.md section on documenting generic helpers, then tests the guide by getting claude to apply it again to to a similar function, _fuzzy_match_names. Genuinely curious if you think this is a decent improvement across both functions. It's also so pretty verbose so we'd need to watch out it isn't biting too often.

CLAUDE.md                            ← new "Docstrings: generic helpers" section
src/ispypsa/translator/helpers.py    ← _resolve_wildcards docstring reworked per the guide
src/ispypsa/templater/helpers.py     ← the guide applied to _fuzzy_match_names as a second worked example

… guide

Review feedback on #126 found the _resolve_wildcards docstring confusing —
both its structure and its coined terminology (wildcardable, designed
drops). Rewording it produced a set of transferable lessons: established
terminology only, a narrative structure that motivates the input's oddities
before the mechanism, precision about compound cases, and verifying
provenance claims against call sites. These are now captured in CLAUDE.md
as a docstring guide for generic helpers, and demonstrated on a second
function in the same situation, _fuzzy_match_names.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/ispypsa/templater/helpers.py 100.00% <ø> (ø)
src/ispypsa/translator/helpers.py 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The greedy loop accepts scores at the threshold (>=), not only above it,
and the canonical sub-region names live in mappings.py, not the nodes
table they're used to build.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@EllieKallmier EllieKallmier left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have percolated a bit and left thought comments but in the end I think this is totally reasonable and not a huge deal if not 'perfected' at any point of our process :)

specific row and a wildcard one. The row that used the fewest wildcards (the
most specific) wins; callers rely on the schema's *_resolve_unambiguously
rule to guarantee there is never a tie.
"""Resolve which row of ``table`` applies to each key combination in

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few thoughts about this particular docstring, that may or may not be actually useful in a general sense (forewarned):

  • It's definitely better described and explains what the function does/doesn't do
  • It's still not like super smooth to read out of context - but that is totally fine and I think good, in a way - it's not meant to be read out of context

I do however feel like in this specific case there's just a bit of a disconnect or slight discomfort with phrasing, but that I think could be clarified (for me - this is such a personal observation so hugest grains of salt!!!) by one of the following:

  • Formatting the 'derived vocabulary' distinctly, e.g., italics or bold or using single quotes: key | key | 'key' -> to be aggressively obviously holding a specific meaning in this context
  • OR: I was thinking that if key_columns were a defined input to this function, that would immediately clarify some of the language and what it relates to (to me). With the full understanding that that's prob not the best/cleanest/most efficient (or necessary!!) solution I just wonder if there are some cases where a small refactor to make a function's function more obvious could be a win...

Ok big thought dump, again honestly I think this is just a personal taste thing and really not that deep, I generally prefer these versions of the docstring to their old versions and am happy to green-light this general concept of 'give more context when a helper is multi-use' :)

Comment thread CLAUDE.md
"""
```

### Docstrings: generic helpers

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in my other chunky comment, generally I think I am pro- this approach of requiring more in-depth explanation when a helper services multiple call sites/cases. I also though don't think more text is always going to be the best approach for every case (whatever 'best' means lol).

-> Also I would lean towards adopting an approach to example-writing in docstrings that encourages writing up multiple examples where there are a few distinct edge cases or potentially unclear operations as an accompanying comment :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants