Skip to content

Conversation

rahlk
Copy link
Contributor

@rahlk rahlk commented Jul 11, 2025

Summary

Fix JSON output formatting and CLI testing issues in CI/CD environments

This PR addresses two critical issues that were preventing proper functionality:

Motivation and Context

Issue #8 was causing the CLI to crash when using --format=json due to Pydantic's model_dump_json() method not supporting the separators parameter that was added in a previous PR.

Issue #9 was causing test failures in CI/CD environments (particularly GitHub Actions) where Typer's CliRunner.invoke() with Rich integration was still emitting ANSI color codes despite color=False, making string assertions fail.

Changes Made

🔧 Fixed JSON Output (Issue #8)

  • Removed unsupported separators argument from BaseModel.model_dump_json() call in __main__.py
  • Updated to use indent=None for compact JSON output instead
  • Replaced deprecated astor.to_source() with built-in ast.unparse() for better Python 3.12+ compatibility
  • Removed astor dependency from pyproject.toml

🎨 Fixed CLI Testing Color Issues (Issue #9)

  • Updated test configuration to explicitly disable colors using env={"NO_COLOR": "1", "TERM": "dumb"}
  • Enhanced test assertions to properly validate JSON output structure
  • Improved test robustness for CI/CD environments

📊 Enhanced Testing Infrastructure

  • Added comprehensive coverage configuration to pyproject.toml
  • Updated test paths and coverage settings
  • Fixed project root path calculation in test fixtures
  • Added proper logging configuration for tests

How Has This Been Tested?

  • ✅ Verified JSON output generation works without crashes
  • ✅ Confirmed CLI tests pass in CI environments without ANSI color code interference
  • ✅ Validated coverage reporting functionality
  • ✅ Tested with Python 3.12+ compatibility

Breaking Changes

None. All changes are backward compatible and improve existing functionality.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the Codellm-Devkit Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

These fixes improve the stability and reliability of the codeanalyzer tool, particularly in automated environments. The removal of the astor dependency in favor of Python's built-in ast.unparse() also reduces external dependencies while maintaining the same functionality with better Python 3.12+ support.

Related Issues:

Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
@rahlk rahlk self-assigned this Jul 11, 2025
@rahlk rahlk added bug Something isn't working documentation Improvements or additions to documentation and removed documentation Improvements or additions to documentation labels Jul 11, 2025
@rahlk rahlk merged commit c8e80e9 into main Jul 11, 2025
@rahlk rahlk deleted the 8-9-fix-json-output-and-decolorize-cli-test-for-github-actions branch July 11, 2025 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant