← ClaudeAtlas

cast-docstring-best-practiceslisted

Apply docstring standards when writing or reviewing Python functions and classes. Use when creating new classes, functions, or methods to ensure proper documentation with description, args, returns, and exceptions.
sridherj/diecast · ★ 3 · AI & Automation · score 72
Install: claude install-skill sridherj/diecast
# DocStringBestPractices Skill Apply these docstring standards when writing or reviewing Python code. ## Reference - `./reference_code/.cursor/rules/bestpractices.mdc` - Google Python Style Guide: https://google.github.io/styleguide/pyguide.html ## Docstring Structure Every function/method must have a docstring with: ```python def function_name(arg1: str, arg2: int) -> ReturnType: """ Short one-line description of what the function does. Longer description if needed. Include: - What the function does - Any assumptions the function makes - Important logic details - If the logic contains multiple steps, number them like 1, 2, 3. You can even use 1.1, 1.2 for sub-steps. Also make sure the function comments also mimic these numbered steps. - If an illustration makes it more easy to understand, include that. Lot of times, I expect devs to only read this instead of actual code. So make it thorough. Args: arg1: Description of arg1. Include any constraints or valid values. arg2: Description of arg2. Note if it can be None or has defaults. Returns: Description of what is returned. - Note corner cases: "Returns None if entity not found" - Note if can return empty: "Returns empty list if no matches" If return value is a dictionary, mention what is the key and what is the value clearly Raises: ValueError: When validation fails (describe when) HTTPException: When entity