Skip to content

Code style: docstrings on their own lines, and checks that keep the rules - #90

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

utkarsh5026 merged 1 commit into
mainfrom
code-style-docstrings

Conversation

@utkarsh5026

Copy link
Copy Markdown
Owner

What this changes

The first two steps of bringing the code in line with the new Code style rules in CLAUDE.md:

  1. Every docstring is reshaped so its quotes sit on their own lines. That's 2,175 docstrings across src/, tests/ and .claude/skills/:

    def human_size(num_bytes: float | None) -> str:
        """
        1536 -> '1.5 KB' (binary units, like the AWS console).
        """
  2. Checks so new code follows the rules:

    • tests/test_style.py fails on a docstring with text beside its quotes. It also fails on a file with more # comments than its allowance in COMMENTS_LEFT, and on one with fewer, until that number is lowered. So comments can only go down.
    • ruff.toml adds B006 (mutable defaults), BLE001 (broad except), ERA001 (commented-out code) and the complexity rules (C901, PLR0912, PLR0913, PLR0915). Files written before these rules keep what they already broke in per-file-ignores; a file comes off that list as it's cleaned up.

Nothing a user sees changed

  • Docstring text and code: for every file, the syntax tree and each docstring's cleaned text (inspect.getdoc, which help() uses) are identical to main.
  • Comments: every comment is identical to main, apart from one header comment removed by hand in agent/toolkits/base.py.
  • Reports: snapshot.py compare shows 319 of 321 outputs identical. The other two are the line numbers in snapshot.py's own traceback for lambda-how-it-works. That case already fails on main, on Python 3.10: NameError: name 'mod' is not defined inside an exec'd list comprehension.
  • Scripts: the ones that hand __doc__ to argparse now strip it, so --help reads as before.
  • CI: check/run.py passes (ruff, imports, package, rules, pytest: 1,164 passed). Its one rules warning, execute_statement in dynamodb.py, was already there on main.

No CHANGELOG entry: nothing a user sees changes.

Next

Step 3: remove the comments and refactor long functions one module per pull request, starting with _kit/.

🤖 Generated with Claude Code

…ules

Every docstring in src/, tests/ and .claude/skills/ now has its quotes on their own lines, rewritten by a script
that kept each docstring's cleaned text and everything outside the docstrings the same (checked by comparing the
syntax trees and every comment with main; the report snapshots match too). Scripts that pass __doc__ to argparse
strip it, so --help reads as before.

CLAUDE.md gets a "Code style" section with the rules, and two checks hold new code to them:
- tests/test_style.py fails on a docstring with text beside its quotes, and on a file with more # comments than
  its number in COMMENTS_LEFT (or fewer, until the number is lowered), so comments only go down.
- ruff.toml adds B006, BLE001, ERA001, C901, PLR0912, PLR0913 and PLR0915; files written before the rules keep
  what they already broke in per-file-ignores, to be taken off as each module is cleaned up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@utkarsh5026
utkarsh5026 merged commit 2e3a03f into main Oct 17, 2026
8 checks passed
@utkarsh5026
utkarsh5026 deleted the code-style-docstrings branch October 17, 2026 16:44
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