python
Python development guidelines and best practices. Use when working with Python code.
What this skill does
# Python Guidelines Standards and best practices for Python development. Follow these guidelines when writing or modifying Python code. ## Design Principles Apply DRY, KISS, and SOLID consistently. Prefer functional methods where relevant; use classes for stateful behavior. Use composition with Protocol classes for interfaces rather than inheritance. Each module should have a single responsibility. Use dependency injection for class dependencies. ## Code Style - **Naming**: Descriptive yet concise names for variables, methods, and classes - **Documentation**: Docstrings for all classes, functions, enums, enum values - **Type hints**: Use consistently; avoid `Any` unless necessary - **Imports**: Avoid barrel exports in `__init__.py`; prefer blank files ## Type Annotations - Use `dict`, `list` instead of `typing.Dict`, `typing.List` - Use `str | None` instead of `Optional[str]` - Include `from __future__ import annotations` at top of files with type hints - Prefer built-in types over typing module equivalents ## Architecture ### Dependency Injection - Always inject dependencies via constructors or methods when using classes - One service class per module (interface and class models allowed in addition) - Use Protocol classes to define interfaces for dependency injection and testing ### Module Organization - Each module focuses on one concern with clear boundaries - Extract reusable methods to avoid duplication - Design for reusability across contexts ### Environment Variables - Use an `environment.py` file with individual methods per variable (e.g., `api_key()` for `API_KEY`, `database_url()` for `DATABASE_URL`) - Co-locate all environment access in one place per package for easier mocking in tests ### Data Models - Use Pydantic v2 for schemas, validation, and data models - Leverage Pydantic's type validation, serialization, and configuration management - Use Pydantic models for API request/response schemas, configuration objects, and data transfer objects ## Testing ### Structure - Tests mirror `src/` directory structure - Test methods start with `test_` - Use test class suites: for `def foo()` create `class TestFoo` - Keep names concise, omit class suite name from method - Always check for appropriate unit tests when changing code ### Quality - Use AAA (Arrange, Act, Assert) pattern - Tests should be useful, readable, concise, maintainable - Avoid tests that create massive diffs or become burdensome ### Tools - Prefer `pytest` over `unittest` - Use `pytest-mock` for mocking - Use `conftest.py` for shared fixtures - Use `tests/__test_<package_name>__` for shared testing code ## Implementation When implementing Python code: - Ensure code passes type checking and tests before committing - Group related changes with tests in atomic commits - Check for existing workflow patterns (spec-first, TDD, etc.) and follow them ## References - For adhoc Python scripts in uv-managed projects, see `references/uv-scripts.md`. - For monorepo-specific patterns using uv and Hatch, see `references/uv-monorepo.md`.
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.