Skip to content

v0.1.27 - Simplified Response Handling and Flatten Logic Refactoring (2025-12-07)

What Changed?

This release refactors the response handling to eliminate unnecessary wrapper layers and consolidate flatten logic. The CommandResponse wrapper has been removed entirely, and Command methods now return DeviceResponse directly. All flatten processing is now handled by ResponseFormatter, resulting in cleaner and more maintainable code.


What's New

Architecture Improvements

What changed: The response handling pipeline has been simplified by removing the intermediate CommandResponse wrapper layer. This makes the API more direct and the code easier to understand.

Before:

cmd = Command(device)
resp = cmd.status()  # -> CommandResponse
print(resp.raw.status)  # Access through .raw wrapper

After:

cmd = Command(device)
resp = cmd.status()  # -> DeviceResponse directly
print(resp.status)  # Direct access

Installation

Quick Start

# Get the release
git checkout v0.1.27

# Setup
uv sync

# Run CLI
uv run kazunoko --help

What's Different from the Last Version?

✅ Added

  • ResponseFormatter._flatten() method now handles all flatten operations

🔧 Changed

  • Breaking Change: Command methods now return DeviceResponse instead of CommandResponse
  • ResponseFormatter now accepts only DeviceResponse (no more CommandResponse support)
  • Removed CommandResponse dataclass entirely
  • Updated all docstrings to reflect direct DeviceResponse access (no .raw needed)

🐛 Fixed

  • Eliminated double flatten processing in the response pipeline
  • Simplified _format_dict() logic in ResponseFormatter

Is It Safe to Upgrade?

Backward Compatible: No (Breaking changes to public API)

Migration Guide:

  • Replace resp.raw.field with resp.field
  • No changes needed for ResponseFormatter usage (still works the same way)
  • Command class API is unchanged, only return types are more direct

Impact on existing users: If you use CommandResponse, you'll need to update code to access fields directly on DeviceResponse. This is a simple find-replace in most cases.


Tests Passed

  • ✅ Builds without errors (Ruff lint: 100% pass)
  • ✅ Type checking compatible (mypy - external stubs only)
  • ✅ Mock device integration tests pass
  • ✅ Flatten logic verified with nested and flat format outputs

Code Changes Summary

Files Modified: 3

  • src/kazunoko/command.py - Removed CommandResponse class, simplified all methods
  • src/kazunoko/formatter.py - Consolidated flatten logic, simplified _format_dict()
  • src/kazunoko/__init__.py - Removed CommandResponse from exports

Lines Changed: 137 deleted, 78 added (59 net reduction)


Release Details

  • Date: 2025-12-07
  • Version: v0.1.27
  • Files Changed: 3
  • Commits:
  • ce003cf - refactor: move flatten logic from CommandResponse to ResponseFormatter
  • 9ff48bb - refactor: remove CommandResponse wrapper, Command now returns DeviceResponse directly

Next Steps

Future improvements to consider:

  • Add comprehensive test suite for response formatting
  • Consider async/await support if needed
  • Optimize flatten logic for very deep nested structures