Skip to content

Add google style guide docstrings to AGENTS.md#747

Open
alexmillane wants to merge 1 commit into
mainfrom
alex/feature/agents_md_docstrings
Open

Add google style guide docstrings to AGENTS.md#747
alexmillane wants to merge 1 commit into
mainfrom
alex/feature/agents_md_docstrings

Conversation

@alexmillane

Copy link
Copy Markdown
Collaborator

Summary

Add docstring guidelines to AGENTS.md

Detailed description

  • Copies in guidelines from Google style (modified slightly to match our style).

@greptile-apps

greptile-apps Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a "Coding Style" section to AGENTS.md covering assert/raises preferences and Google-style docstring guidelines for AI agents to follow. The content itself is useful, but there are structural and formatting issues that should be addressed before merging.

  • A duplicate section header is introduced: ## Coding Style (new) sits immediately after the existing ## Coding style (line 38), with overlapping assert/raises guidance appearing in both — the new content should be merged into the existing section.
  • The example docstring is missing the blank lines between the summary, extended description, and Args:/Returns: sections that Google style mandates, meaning AI agents following the example would produce non-conforming docstrings.
  • Two minor grammar issues in the new prose: "such an check" and a malformed "(i.e)" abbreviation.

Confidence Score: 3/5

The PR is documentation-only, but the example docstring directly contradicts the Google style it claims to demonstrate, and the file now has two overlapping coding style sections — both issues would actively mislead agents following this guide.

The duplicate section and the incorrect example docstring (missing required blank lines between sections) are functional errors in a style guide document whose primary purpose is to instruct AI agents on correct formatting. An agent that faithfully copies the example will produce docstrings that don't match Google style.

AGENTS.md — the new section structure and the example docstring both need corrections.

Important Files Changed

Filename Overview
AGENTS.md Adds "Coding Style" section with Checks/Asserts and Docstrings subsections; introduces a duplicate section header alongside the existing "Coding style" section, the example docstring is missing required blank lines between Google-style sections, and there are two grammar issues in the new prose.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[AGENTS.md] --> B["## Coding style (existing, line 38)"]
    A --> C["## Coding Style (new, line 43)"]
    B --> B1["assert over if-raise bullet"]
    B --> B2["PR body format bullet"]
    C --> C1["### Checks/Asserts\n(duplicates B1 content)"]
    C --> C2["### Docstrings\nGoogle style guidelines"]
    C2 --> D["#### Args"]
    C2 --> E["#### Returns"]
    C2 --> F["#### Raises\n(says: not documented)"]
    C2 --> G["#### Example\n⚠️ Missing blank lines\nbetween sections"]
Loading

Comments Outside Diff (1)

  1. AGENTS.md, line 38-50 (link)

    P1 Duplicate section with redundant assert/raises guidance

    The file now has two separate coding style sections: ## Coding style (line 38) and the newly added ## Coding Style (line 43). The assert/raises preference is documented in both — as a bullet in the original section and again as the "Checks/Asserts" subsection. AI agents (and humans) parsing this file will encounter conflicting or duplicated guidance. The new content should be merged into the existing ## Coding style section rather than creating a second one.

Reviews (1): Last reviewed commit: "Add google style guide docstrings to AGE..." | Re-trigger Greptile

Comment thread AGENTS.md
Comment on lines +78 to +90
"""Fetches rows from a Smalltable.
Retrieves rows pertaining to the given keys from the Table instance
represented by table_handle. String keys will be UTF-8 encoded.
Args:
table_handle: An open smalltable.Table instance.
keys: A sequence of strings representing the key of each table
row to fetch. String keys will be UTF-8 encoded.
require_all_keys: If True only rows with values set for all keys will be
returned.
Returns:
A dict mapping keys to the corresponding table row data
fetched. Each row is represented as a tuple of strings.
"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 The example docstring is missing the blank lines between the summary sentence, the extended description paragraph, and the Args: section that Google style requires. As written, an AI agent following this example would produce non-conforming docstrings.

Suggested change
"""Fetches rows from a Smalltable.
Retrieves rows pertaining to the given keys from the Table instance
represented by table_handle. String keys will be UTF-8 encoded.
Args:
table_handle: An open smalltable.Table instance.
keys: A sequence of strings representing the key of each table
row to fetch. String keys will be UTF-8 encoded.
require_all_keys: If True only rows with values set for all keys will be
returned.
Returns:
A dict mapping keys to the corresponding table row data
fetched. Each row is represented as a tuple of strings.
"""
"""Fetches rows from a Smalltable.
Retrieves rows pertaining to the given keys from the Table instance
represented by table_handle. String keys will be UTF-8 encoded.
Args:
table_handle: An open smalltable.Table instance.
keys: A sequence of strings representing the key of each table
row to fetch. String keys will be UTF-8 encoded.
require_all_keys: If True only rows with values set for all keys will be
returned.
Returns:
A dict mapping keys to the corresponding table row data
fetched. Each row is represented as a tuple of strings.
""

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment thread AGENTS.md
Comment on lines +47 to +48
In Arena we prefer asserts over if...raises in most cases where such an check represents a coding error
(i.e) something that shouldn't be recovered from. Asserts are briefer than the exception based counterpart.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Two minor grammar issues: "such an check" should be "such a check", and "(i.e)" is missing its comma and a closing parenthesis around the clause — the standard abbreviation is "(i.e.,)".

Suggested change
In Arena we prefer asserts over if...raises in most cases where such an check represents a coding error
(i.e) something that shouldn't be recovered from. Asserts are briefer than the exception based counterpart.
In Arena we prefer asserts over if...raises in most cases where such a check represents a coding error
(i.e., something that shouldn't be recovered from). Asserts are briefer than the exception based counterpart.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review: Add google style guide docstrings to AGENTS.md

Good initiative to codify docstring conventions — this will help both human contributors and AI agents maintain consistency. A few issues to address before merging:

Key Findings

1. Duplicate section header (high)

The file already contains a ## Coding style section (line 38, lowercase 's') with the assert preference bullet. This PR adds a new ## Coding Style (uppercase 'S') section immediately after it. This creates two nearly-identically-named top-level sections, which is confusing for both readers and AI agents navigating by heading. The new content should either be merged into the existing section or the existing section should be replaced.

2. Redundant assert guidance (medium)

The existing ## Coding style section already states:

Prefer assert condition, "message" over if not condition: raise ValueError("message") for internal invariant checks.

The new ### Checks/Asserts sub-section restates this at greater length. Consider consolidating — either expand the existing bullet in-place and remove the new sub-section, or remove the existing bullet and keep only the new sub-section under a unified heading.

3. Grammar/punctuation nits (low)

  • "such an check" → "such a check"
  • "(i.e)" → "(i.e.,)" or "i.e.,"
  • "We don't document raises in Arena" — missing period
  • "Here is an example docstring" — missing period/colon

4. Example not project-relevant (suggestion)

The fetch_smalltable_rows example is copied directly from Google's style guide and references smalltable.Table, which has no connection to Isaac Lab/Arena. Consider replacing it with a small Arena-relevant example (e.g., a function from isaaclab_arena) to make the guidance more concrete for contributors working in this codebase.

5. Docstring example doesn't follow its own rules (medium)

Per Google style, a multi-line docstring should have a blank line between the summary line and the elaboration paragraph. The example shows:

"""Fetches rows from a Smalltable.
Retrieves rows pertaining to...

It should be:

"""Fetches rows from a Smalltable.

Retrieves rows pertaining to...

6. Trailing double blank line (nit)

There are two consecutive blank lines before ## Conventions — should be one.


Summary: The main structural issue is the duplicate heading and redundant content (findings 1 & 2). Once those are resolved and the minor grammar fixes applied, this looks good to merge. The example swap (finding 4) is a nice-to-have but not blocking.

Comment thread AGENTS.md
@@ -40,6 +40,57 @@ Use the `dev-container` skill for build, start, attach, and exec inside the cont
- Prefer `assert condition, "message"` over `if not condition: raise ValueError("message")` for internal invariant checks. (Formatting, imports, and typing are enforced by `pre-commit` — see `.pre-commit-config.yaml`.)
- PR bodies follow `.github/pull_request_template.md` — a one-line Summary plus 2–5 detail bullets. Resist the agent default of long, multi-section descriptions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This creates a duplicate top-level section — the file already has ## Coding style (lowercase 's') at line 38 with assert guidance. Recommend merging the new content into the existing section rather than creating a parallel one.

Suggested change
## Coding Style

(and remove the old ## Coding style section above, consolidating its content here)

Comment thread AGENTS.md
## Coding Style

### Checks/Asserts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
In Arena we prefer asserts over if...raises in most cases where such a check represents a coding error

Also: "(i.e)" on the next line should be "(i.e.,)".

Comment thread AGENTS.md
def fetch_smalltable_rows(
table_handle: smalltable.Table,
keys: Sequence[bytes | str],
require_all_keys: bool = False,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is Google's internal example (smalltable.Table). Consider swapping for a small Arena-relevant snippet to make the guide more concrete for contributors. Even a simple get_observation_space(env_cfg: EnvCfg) -> gym.spaces.Space would anchor the guidance in the project domain.

Comment thread AGENTS.md
row to fetch. String keys will be UTF-8 encoded.
require_all_keys: If True only rows with values set for all keys will be
returned.
Returns:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The docstring example should have a blank line between the summary and the extended description per Google style:

    """Fetches rows from a Smalltable.

    Retrieves rows pertaining to the given keys from the Table instance
    ...

Without it, the example contradicts the guidance it's illustrating.

Comment thread AGENTS.md
- Prefer `assert condition, "message"` over `if not condition: raise ValueError("message")` for internal invariant checks. (Formatting, imports, and typing are enforced by `pre-commit` — see `.pre-commit-config.yaml`.)
- PR bodies follow `.github/pull_request_template.md` — a one-line Summary plus 2–5 detail bullets. Resist the agent default of long, multi-section descriptions.

## Coding Style

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We already have a coding style section just above. Suggestion to remove.

Comment thread AGENTS.md

### Checks/Asserts

In Arena we prefer asserts over if...raises in most cases where such an check represents a coding error

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks like a duplicate of what we aleady state above on line 40, eg
- Prefer assert condition, "message"overif not condition: raise ValueError("message")for internal invariant checks. (Formatting, imports, and typing are enforced bypre-commit— see.pre-commit-config.yaml.)

Comment thread AGENTS.md
The raises-based approach is more verbose (for example it always uses multiple lines), and because
this type of error is not intended to be recovered from, it offers no advantage.

### Docstrings

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I feel like the follwing is a pretty verbose paragraph to describe how to write (good) docstrings. Slightly ironic given the existing doc explicitly states "Resist the agent default of long, multi-section descriptions." :)
It's generally recommended to keep the agents.md at or below 150-300 lines of text as it might add to general context rot in other areas. This section alone would add a considerably large part.

Did you have any luck in adding a concise section to the coding style section like

- Docstrings: Google style (https://google.github.io/styleguide/pyguide.html#383-functions-and-methods).
- Prefer one line; a 2–3 line paragraph may follow if needed.
- Document `Args` and `Returns`, but **not** `Raises`. Omit `Returns` when it only returns None
    or the summary already covers it.

maybe with a short example?

@cvolkcvolk cvolkcvolk Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Eg we refer to the google styleguide (Edit: maybe without linking the URL) and then only state our deltas explicitely

Comment thread AGENTS.md

Prefer short docstrings. Where a single line is not sufficient, a short (i.e. 2-3 line)
paragraph can follow. Document args and returns, but not raises.
We follow google-style for docstrings which is repeated below:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

google-style -- URL?

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.

3 participants