Skip to content

Add version-matrix command for Python version detection#75

Merged
tschm merged 6 commits intomainfrom
version-matrix
Feb 8, 2026
Merged

Add version-matrix command for Python version detection#75
tschm merged 6 commits intomainfrom
version-matrix

Conversation

@tschm
Copy link
Member

@tschm tschm commented Feb 8, 2026

Summary

  • Adds new version-matrix command to rhiza-tools CLI
  • Provides unified interface for determining supported Python versions from pyproject.toml
  • Outputs JSON array of versions matching the requires-python specifier
  • Maintains compatibility with existing .rhiza/utils/version_matrix.py script

Features

  • CLI Command: rhiza-tools version-matrix outputs supported versions as JSON
  • Custom Options:
    • --pyproject: Specify custom path to pyproject.toml
    • --candidates: Provide custom list of candidate versions to evaluate
  • Type Safe: Full mypy strict type checking compliance
  • Well Documented: Comprehensive docstrings and help text

Usage

# Basic usage
$ rhiza-tools version-matrix
["3.11", "3.12", "3.13", "3.14"]

# With custom candidates
$ rhiza-tools version-matrix --candidates "3.10,3.11,3.12"
["3.11", "3.12"]

Test plan

  • Command produces identical output to original script
  • All type checking passes (make mypy)
  • All linting and formatting passes (make fmt)
  • Command appears in help output with proper documentation
  • Custom options work correctly
  • Makefile target make version-matrix still works

🤖 Generated with Claude Code

tschm and others added 6 commits February 8, 2026 15:08
Provides a unified interface for determining supported Python versions from pyproject.toml, making it easier to use in scripts and CI workflows alongside other rhiza-tools commands.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implements 44 tests covering all functions and edge cases:
- parse_version: handles valid versions, suffixes, and invalid inputs
- _check_operator: tests all comparison operators (>=, <=, >, <, ==, !=)
- satisfies: validates single/multiple specifiers and complex combinations
- get_supported_versions: covers success cases and error conditions
- version_matrix_command: tests defaults, custom options, and error handling

Coverage: 78 statements, 0 missed (100%)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Removes the module from sys.modules before using runpy.run_module() to avoid
the warning: "module found in sys.modules after import of package but prior
to execution; this may result in unpredictable behaviour"

The fix ensures clean module execution by temporarily removing the module from
sys.modules and restoring it afterwards, eliminating the warning while
maintaining test coverage.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Renamed test_version_matrix.py to test_version_matrix_command.py to avoid
naming conflict with .rhiza/tests/utils/test_version_matrix.py which tests
the original utility script.

This resolves the pytest error:
"imported module 'test_version_matrix' has this __file__ attribute which is
not the same as the test file we want to collect"

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Adds two test cases to test_cli_commands.py that cover the CLI wrapper
function for version-matrix, testing both default and custom candidate
parsing. This brings test coverage from 99% to 100%.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@tschm tschm merged commit f948405 into main Feb 8, 2026
15 checks passed
@tschm tschm deleted the version-matrix branch February 8, 2026 11:30
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