← ClaudeAtlas

cast-python-best-practiceslisted

Apply these Python coding standards when writing or reviewing Python code. Use when creating new Python files, refactoring code, or ensuring code quality and style compliance.
sridherj/diecast · ★ 3 · AI & Automation · score 72
Install: claude install-skill sridherj/diecast
# PythonBestPractices Skill Apply these Python coding standards when writing or reviewing code. ## Reference - `./reference_code/.cursor/rules/bestpractices.mdc` - Google Python Style Guide: https://google.github.io/styleguide/pyguide.html ## Style Guidelines ### Naming Conventions | Type | Convention | Example | |------|------------|---------| | Variables/functions | snake_case | `project_id`, `get_by_id()` | | Classes | PascalCase | `ProjectService`, `ProjectEntity` | | Constants | UPPER_SNAKE_CASE | `MAX_LIMIT`, `DEFAULT_STATUS` | | Private members | Leading underscore | `_session`, `_repository` | ### Formatting - 4 spaces per indentation level - Max line length: 80 characters - Private members start with `_` and must be typed ### Type Hints ```python # Always include type hints def get_project(self, project_id: str) -> Optional[ProjectSchema]: pass # For class members class Service: _session: Session _repository: ProjectRepository ``` ## Code Design ### Small, Single-Responsibility Functions ```python # GOOD - Single responsibility def validate_tenant_id(tenant_id: str) -> None: assert tenant_id is not None, 'Tenant ID is required' def fetch_project(self, tenant_id: str, project_id: str) -> ProjectEntity: return self._repository.get_by_id(tenant_id, project_id) # BAD - Multiple responsibilities def validate_and_fetch_project(self, tenant_id, project_id): if not tenant_id: raise ValueError("No tenant") # ... validation + fetc