hass.tibber_prices/docs/development/coding-guidelines.md
Julian Pawlowski df79afc87e docs: restructure documentation and add AI development disclosure
Created professional documentation structure:

**User Documentation (docs/user/):**
- README.md: Documentation hub with quick start guide
- Placeholder files for future content migration:
  * installation.md, configuration.md, sensors.md
  * services.md, automation-examples.md, troubleshooting.md

**Developer Documentation (docs/development/):**
- README.md: Comprehensive contributor guide with AI section
- setup.md: DevContainer and environment setup
- architecture.md: Code structure overview
- testing.md: Testing guidelines
- coding-guidelines.md: Style guide and critical patterns
- release-management.md: Complete release workflow documentation

**AI Development Disclosure:**
- README.md: "🤖 Development Note" section before license
  * Honest disclosure about extensive AI assistance
  * Quality assurance measures mentioned
  * Invitation for bug reports with positive tone
- docs/development/README.md: Detailed AI section
  * What AI handles (patterns, generation, refactoring)
  * Benefits (rapid development, consistency)
  * Limitations (edge cases, complex patterns)
  * Quality assurance process
- CONTRIBUTING.md: Brief AI note with practical tip

**Updated:**
- README.md: Simplified to landing page with documentation links
- CONTRIBUTING.md: Modernized with new docs structure
- copilot-instructions.md: Added documentation organization section

Impact: Clear separation of user vs. developer documentation following
open-source best practices. Transparent about AI-assisted development
approach without being defensive. Scalable structure for future growth.
2025-11-09 14:25:27 +00:00

1.2 KiB

Coding Guidelines

Note: For complete coding standards, see .github/copilot-instructions.md.

Code Style

  • Formatter/Linter: Ruff (replaces Black, Flake8, isort)
  • Max line length: 120 characters
  • Max complexity: 25 (McCabe)
  • Target: Python 3.13

Run before committing:

./scripts/lint

Import Order

  1. Python stdlib (specific types only)
  2. Third-party (homeassistant.*, aiohttp)
  3. Local (.api, .const)

Critical Patterns

Time Handling

Always use dt_util from homeassistant.util:

from homeassistant.util import dt as dt_util

price_time = dt_util.parse_datetime(starts_at)
price_time = dt_util.as_local(price_time)  # Convert to HA timezone
now = dt_util.now()

Translation Loading

# In __init__.py async_setup_entry:
await async_load_translations(hass, "en")
await async_load_standard_translations(hass, "en")

Price Data Enrichment

Always enrich raw API data:

from .price_utils import enrich_price_info_with_differences

enriched = enrich_price_info_with_differences(
    price_info_data,
    thresholds,
)

See .github/copilot-instructions.md for complete guidelines.