Skip to content

Conversation

@nwaughachukwuma
Copy link

@nwaughachukwuma nwaughachukwuma commented Apr 20, 2025

Summary

This PR modernizes seewav by adding continuous-integration, full type-hints, stricter unit-testing and a clearer, more ergonomic CLI/API.


✨ Key Features & Improvements

  1. GitHub Actions CI

    • Runs the test-suite on Python 3.9 → 3.12
    • Includes pytest-cov; uploads an XML coverage artefact
  2. 100% Type-annotated Public API

    • All public helpers in seewav.py now have explicit PEP-484 annotations
    • New meta-test (tests/test_signatures.py) fails the build if a public function lacks annotations
  3. Unified Size Handling

    • New --size WxH CLI flag (e.g. --size 640x360)
    • Existing -W/--width and -H/--height remain with defaults (480 × 300); --size overrides them
    • Library call continues to accept the size=(w, h) tuple
  4. Robust Argument Validation

    • Added seewav.parse_size_token helper
    • Expanded test-suite (tests/test_arguments.py) checks:
      • parse_size_token – valid & invalid paths
      • parse_color – valid & invalid RGB strings
      • read_audio – fails gracefully on non-audio files
      • visualize – detects channel/--stereo mismatches
    • Test count increased from 9 → 27; all green
  5. Documentation Updates

    • README gains a "Library usage & type-safety" section and updated option table:
      --size WxH            Output video dimension (e.g. 640x360)
      -W, --width WIDTH     Width in pixels (default 480)
      -H, --height HEIGHT   Height in pixels (default 300)
      
    • Example snippet for programmatic use with size=(640, 360)

🛠️ Implementation Notes

  • CI Workflow.github/workflows/ci.yml
    • Installs minimal deps (numpy, tqdm, pytest, pytest-cov) and optional ffmpeg
  • Helper Functions
    • parse_size_token(token: str) -> tuple[int, int]
    • Improved error messages via fatal()
  • Backward Compatibility
    • Width/height flags preserved; no breaking change for existing users
  • Coverage
    • .coveragerc excludes tests/venv; --cov-report=term-missing --cov-report=xml in CI

🔍 How to Review

  1. API surface – inspect new/changed functions & type-hints in seewav.py
  2. CLI behaviour – run:

seewav --size 800x450 in.wav out.mp4
seewav -W 800 -H 450 in.wav out.mp4 # still works

  1. Tests – execute pytest -vv locally; 27 tests including argument-validation and meta type-checking should pass
  2. CI – confirm new workflow passes on all Pythons

This PR brings the project up to date with modern Python best-practices, increases test coverage, and lays the groundwork for future features with confidence in correctness.

Co-author: OpenAI o3 model via Codex CLI

@nwaughachukwuma
Copy link
Author

cc @adefossez

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.

1 participant