Skip to content

Refactor: PEP 257 docstrings, 80 char line limit, and comprehensive documentation#24

Merged
eman merged 6 commits intomainfrom
docs-refactor-pep257-80char
Oct 21, 2025
Merged

Refactor: PEP 257 docstrings, 80 char line limit, and comprehensive documentation#24
eman merged 6 commits intomainfrom
docs-refactor-pep257-80char

Conversation

@eman
Copy link
Copy Markdown
Owner

@eman eman commented Oct 21, 2025

Summary

This PR implements a comprehensive refactor of the codebase to adhere to Python coding standards and improves the documentation structure significantly.

Code Changes

PEP 257 Compliance

  • Applied PEP 257 docstring conventions across all Python modules
  • Ensured one-line summaries for all functions, classes, and methods
  • Proper spacing between summary and detailed descriptions
  • Enhanced inline documentation throughout

PEP 8 Line Length

  • Migrated from 100 to 80 character line limit
  • Reformatted all source code to comply
  • Updated pyproject.toml configuration

Code Quality

  • Improved type hints and function signatures
  • Enhanced error messages and logging
  • Better structured exception handling

Documentation Changes

New Structure

Reorganized Sphinx documentation into logical sections:

  • Installation - Setup and requirements
  • Quickstart - Get started quickly
  • Python API - Complete API reference
  • Protocol - REST API and MQTT protocol details
  • User Guides - Feature-specific tutorials
  • Development - Contributing and history

New Documentation Files

  • docs/installation.rst - Installation instructions
  • docs/quickstart.rst - Quick start guide
  • docs/configuration.rst - Configuration reference
  • docs/python_api/ - Comprehensive API docs (auth_client, api_client, mqtt_client, models, events, constants, CLI, exceptions)
  • docs/protocol/ - REST API and MQTT protocol documentation
  • docs/guides/ - User guides for TOU, Reservations, Energy Monitoring, Events, Auto Recovery, Command Queue
  • docs/development/ - Contributing guide and project history

API Documentation

  • Auth Client - Full authentication workflow and credential management
  • API Client - Complete REST API client documentation with examples
  • MQTT Client - Comprehensive MQTT client guide with real-time features
  • Models - Data models, enums, and constants
  • Events - Event system and callbacks
  • CLI - Command-line interface documentation

User Guides

  • Time of Use - Configure TOU schedules, including OpenEI API integration example
  • Reservations - Reserve hot water with JSON schema documentation
  • Energy Monitoring - Track energy usage and efficiency
  • Event System - Handle device and system events
  • Auto Recovery - Automatic reconnection handling
  • Command Queue - Offline command queuing

Protocol Documentation

  • REST API - Complete endpoint reference with request/response examples
  • MQTT Protocol - Message formats, topics, and payloads
  • Device Status Fields - All status fields with conversion formulas
  • Device Features - Feature detection and capabilities
  • Error Codes - Complete error code reference

Examples

  • Added examples/tou_openei_example.py - Demonstrates OpenEI API integration for TOU schedules

Cleanup

  • Removed redundant/outdated RST files
  • Consolidated overlapping documentation
  • Removed temporary scripts and status files

Testing

✅ All linting checks pass (make ci-lint)
✅ Type checking passes (python3 -m mypy src/nwp500)
✅ Documentation builds without warnings (tox -e docs)
✅ All tests pass (pytest)

Breaking Changes

None - all changes are backward compatible

Files Changed

  • 65 files changed
  • 9,401 insertions
  • 5,411 deletions
  • Net improvement in documentation coverage and code quality

…ocumentation

Major Changes:
- Applied PEP 257 docstring conventions across all Python modules
- Migrated from 100 to 80 character line limit per PEP 8
- Comprehensive documentation refactor with improved organization

Code Changes:
- Updated all docstrings to follow PEP 257 format (one-line summaries, proper spacing)
- Reformatted code to adhere to 80 character line limit
- Enhanced inline documentation throughout the codebase
- Improved type hints and function signatures

Documentation Changes:
- Reorganized Sphinx documentation for better discoverability
- Created structured sections: Installation, Quickstart, Python API, Protocol, Guides, Development
- Added comprehensive API client, MQTT client, and Auth client documentation
- Created user guides for Time of Use, Reservations, Energy Monitoring, and Events
- Added protocol documentation for REST API and MQTT messages
- Included complete module-level API reference with autodoc
- Added OpenEI integration example for TOU schedules
- Removed redundant/outdated documentation files

New Documentation Files:
- docs/installation.rst - Installation instructions
- docs/quickstart.rst - Quick start guide
- docs/configuration.rst - Configuration reference
- docs/python_api/*.rst - Python API documentation (auth, api_client, mqtt_client, models, etc.)
- docs/protocol/*.rst - REST API and MQTT protocol documentation
- docs/guides/*.rst - User guides (TOU, reservations, energy monitoring, events)
- docs/development/*.rst - Development and contribution guides

Removed Files:
- Consolidated and removed obsolete RST files (API_CLIENT.rst, MQTT_CLIENT.rst, etc.)
- Removed temporary scripts and status files

All changes maintain backward compatibility and pass CI checks (linting, type checking, tests).
eman and others added 2 commits October 20, 2025 23:09
…sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@eman eman requested a review from Copilot October 21, 2025 06:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a comprehensive refactor to improve code quality and documentation structure by migrating to an 80-character line limit, applying PEP 257 docstring conventions, and reorganizing Sphinx documentation into a logical hierarchy. The changes improve readability, maintainability, and provide comprehensive API and protocol documentation while maintaining full backward compatibility.

Key Changes:

  • Applied PEP 257 docstring conventions across all Python modules with one-line summaries and proper spacing
  • Migrated from 100 to 80 character line limit as specified in pyproject.toml
  • Reorganized documentation into Installation, Quickstart, Python API, Protocol, User Guides, and Development sections

Reviewed Changes

Copilot reviewed 63 out of 65 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pyproject.toml Updated line-length configuration from 100 to 80 characters
tests/*.py Reformatted to 80-char line limit with proper line breaks for function calls
src/nwp500/*.py Applied PEP 257 docstrings and 80-char line limit throughout core modules
src/nwp500/cli/*.py Reformatted CLI modules with improved docstrings and line breaks
docs/*.rst Created comprehensive documentation structure with API reference, guides, and protocol details
examples/*.py Added OpenEI integration example and updated README with detailed usage instructions

eman and others added 3 commits October 20, 2025 23:16
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Remove redundant int() cast (casting int to int is no-op)
- Clarify comments to indicate float vs int handling
- Fix unrelated line length issues in mqtt_utils.py
…ted method

- Simplify price encoding logic in build_tou_period() by checking if NOT int first
  (avoids redundant int-to-int casting and mypy unreachable code warnings)
- Remove deprecated _start_reconnect_task() method from NavienMqttClient
  (reconnection is now fully handled by MqttReconnectionHandler)
@eman eman merged commit ce4695e into main Oct 21, 2025
10 checks passed
@eman eman deleted the docs-refactor-pep257-80char branch October 21, 2025 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants