Python docstrings
Skill callowayproject/wiki-toolkit/.claude/skills/python-docstrings
USE WHEN writing python docstrings or asked to document Python code.From its SKILL.md
npx -y skills add callowayproject/wiki-toolkit --skill python-docstringsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
3.2 KB, as published. Nobody here has run it
Python Docstring Guide
TL;DR Rules
- Use triple double quotes:
""". - Docstring is the first statement in module/class/function.
- Summary line: one sentence, present tense, ends with
.,?, or!. - If more content exists: blank line, then body aligned with opening quotes.
- Use Google-style sections with 4-space hanging indent.
- Do not repeat the function/class name or include types in
Args. Argsorder matches signature; omitselfandcls.- Use
Deprecated:section when applicable. - Use Markdown for inline styling and object links:
[name][full.path.to.name].
Section Order (Google Style)
Common order (include only what applies):
- Summary Line
- Extended Summary (optional)
- Deprecated (if applicable)
- Args (if applicable)
- Returns or Yields (if applicable)
- Raises (if applicable)
- Examples (optional)
By Object Type
- Module: Summary, Extended Summary, Deprecated (if needed).
- Class: Summary, Extended Summary, Deprecated, Examples; put init params in
Args. - Function/Method/Property/Generator: use full section order as needed.
- Constant/Attribute: Summary; optional Extended Summary/Deprecated/Examples.
Summary Line
Do not use variable names or the object name.
Yes:
class CheeseShopAddress:
"""The address of a cheese shop."""
No:
class CheeseShopAddress:
"""Class that describes the address of a cheese shop."""
Extended Summary
Short prose that clarifies behavior. Keep parameter details in Args.
Deprecated
Include: removal version, reason (if useful), replacement.
def count_by_twos(start: int, end: int) -> list:
"""
Provide a list of every other number between two numbers.
Deprecated:
Removed in 2.0. Use [`count_by`][full.path.to.count_by].
"""
Args
- List in signature order.
- Omit
self/cls. - No types; rely on type hints.
- Optional args start with
Optional;and may include default.
Args:
table_handle: An open `smalltable.Table` instance.
keys: A sequence of strings representing the key of each table row.
require_all_keys: Optional; If `True`, only rows with values set for all keys
will be returned. (Default: `False`)
Returns
Describe the returned value(s), especially if complex.
Returns:
A dict mapping keys to row tuples.
Yields
Use like Returns, but for generators.
Raises
List exceptions and conditions.
Raises:
IOError: Error accessing the smalltable.
Examples
Use doctest or fenced code blocks. Separate multiple examples with blank lines.
"""
Examples:
>>> print("hello!")
hello!
>>> a = 0
>>> a += 1
>>> a
1
"""
Placement
- Module docstring comes after any file header and before imports.
- Class docstring is indented to class scope.
- Attribute/constant docstring goes immediately below the definition.
NAME: str = "Simple Simon"
"""Name of the project."""
Notes
These guidelines follow Google style, not PEP-287. Derived from the LSST DM Developer Guide.