--- description: Python style — PEP 8, typing, and safe patterns globs: **/*.py alwaysApply: false --- # Python Standards - Follow PEP 8. Use 4-space indentation and `snake_case` for functions/variables. - Add type hints to all public function signatures and return types. - Use `pathlib.Path` instead of string path concatenation. - Prefer f-strings over `.format()` or `%` formatting. - Use context managers (`with`) for files, DB connections, and locks. - Catch specific exceptions; never use bare `except:` or `except Exception:` without re-raising. - Use `logging` instead of `print()` in application code. - Virtual environments: never commit `venv/` or `__pycache__/`. - Prefer `dataclasses` or `pydantic` models over untyped dicts for structured data. - Use `if __name__ == "__main__":` guards in runnable scripts.