Skip to content

Code style: _kit/ without comments, its long functions split up - #91

Merged
utkarsh5026 merged 1 commit into
mainfrom
code-style-kit
Oct 17, 2026
Merged

utkarsh5026 merged 1 commit into
mainfrom
code-style-kit

Conversation

@utkarsh5026

Copy link
Copy Markdown
Owner

Step 3 of the code style work, for _kit/. Stacked on #90: this PR targets that branch. Merge #90 first, and GitHub will retarget this one to main.

What changed

Comments. All 136 # comments in _kit/ are gone. What each one said now lives in one of two places:

  • A docstring: each dataclass's fields, each module's limits, and why a helper works the way it does.
  • A name: _FILTER_MIN_ROWS, _SCROLL_ROWS, _SHORT_CELL, _LINE_EVERY, _PATH_CHARACTERS, _source_offset, ...

What's left is directives: noqa, plus the one type: ignore that was already there.

Long functions split into steps:

Before After
render._table_html: 120 lines, complexity 21 a 40-line function that reads as its steps, calling _column_texts, _table_sorts, _header_html, _cell_td, _row_attributes, _columns_menu, _filter_controls and _table_frame
view._BaseView._progress: closures over one-item lists (bar[0], started[:]) a _ProgressLine class with tick, _update_bar, _update_line and clear. It writes to the terminal through _BaseView._progress_to_terminal, so rules.py's "only the View prints" rule still holds
window._Explorer._later: complexity 13, an inner coroutine a _Job record, run by _run_now or _run_in_background
fmt._zone_from: complexity 11 _offset_zone and _named_zone (with _zone_places)
highlight._python_html: complexity 13 its colour rules in _python_css

Intentional broad excepts. These are guards on purpose and carry # noqa: BLE001: a widget callback's error is shown in the window, a background job's error goes to its failed handler, and tqdm falls back to the plain progress line. Two constructors whose parameters really belong together carry # noqa: PLR0913: _JsonTree and _Picker.

_kit/ comes off both allowance lists, ruff.toml's per-file-ignores and tests/test_style.py's COMMENTS_LEFT, so from now on it's held to every rule.

Nothing a user sees changed

  • Reports: snapshot.py compare against the baseline shows 319 of 321 outputs identical, no names lost, and the same AWS operations. The two differences are the known snapshot.py traceback line numbers for lambda-how-it-works, which already fails on main (see Code style: docstrings on their own lines, and checks that keep the rules #90).
  • CI: check/run.py passes: ruff, imports, package, rules (0 errors), and pytest with 1,164 passed and 16 skipped.
  • Patch points: the things tests reach into still sit where the tests look for them: viewmod._progress_bar_class, time.monotonic, x._tasks and x._said.

No CHANGELOG entry: nothing a user sees changes.

🤖 Generated with Claude Code

Every # comment in _kit/ is gone: what it said is in a docstring now (a dataclass's fields, a module's limits, why
a helper does what it does), or in a name (_FILTER_MIN_ROWS, _SCROLL_ROWS, _LINE_EVERY, _source_offset). The
functions over ruff's limits are split into steps:

- render._table_html reads as its steps: the columns' texts, which ones sort and filter, the header and body
  cells, the Columns menu, the filters, and the frame around them, each a helper of its own.
- view._BaseView._progress keeps its state on a _ProgressLine instead of closures over one-item lists; the line
  prints through the View (_progress_to_terminal), so rules.py's print rule holds.
- window._Explorer._later keeps a background job as a _Job and runs it with _run_now or _run_in_background.
- fmt._zone_from hands offsets to _offset_zone and names to _named_zone; highlight._python_html's colours come
  from _python_css.

The broad excepts that are guards on purpose (a widget callback's error said in the window, tqdm falling back
to the plain line) carry noqa: BLE001, and _kit/ is off ruff.toml's per-file-ignores and tests/test_style.py's
comment allowances. Every report renders as before (snapshot.py compare: only the known traceback line numbers in
lambda-how-it-works differ).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from code-style-docstrings to main October 17, 2026 16:44
@utkarsh5026
utkarsh5026 merged commit 9d5e0bb into main Oct 17, 2026
8 checks passed
@utkarsh5026
utkarsh5026 deleted the code-style-kit branch October 17, 2026 16:46
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.

1 participant