diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 0000000..1ef7eac --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,38 @@ +name: Pytest Tests + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pytest pytest-cov + + - name: Run tests + run: | + pytest tests/ -v --cov=src --cov-report=xml --cov-report=html + + - name: Upload test results + uses: actions/upload-artifact@v4 + if: always() + with: + name: pytest-results-${{ matrix.python-version }} + path: | + junit.xml + htmlcov/ \ No newline at end of file diff --git a/src/jrdev/commands/model.py b/src/jrdev/commands/model.py index bf77499..d9c7397 100644 --- a/src/jrdev/commands/model.py +++ b/src/jrdev/commands/model.py @@ -4,7 +4,7 @@ Model command implementation for the JrDev terminal. Manages the user's list of available models and the active chat model. """ -from typing import Any, List +from typing import Any, List, Union from jrdev.ui.ui import PrintType from jrdev.utils.string_utils import is_valid_context_window, is_valid_cost, is_valid_name @@ -22,7 +22,7 @@ def _parse_bool(val: str) -> bool: # pylint: disable=too-many-return-statements -def _parse_model_arguments(app, args: List[str], start_idx: int) -> dict | None: +def _parse_model_arguments(app, args: List[str], start_idx: int) -> Union[dict, None]: """Parse and validate model arguments starting from given index.""" name = args[start_idx] provider = args[start_idx + 1] diff --git a/src/jrdev/file_operations/confirmation.py b/src/jrdev/file_operations/confirmation.py index 3f28c35..f5d3681 100644 --- a/src/jrdev/file_operations/confirmation.py +++ b/src/jrdev/file_operations/confirmation.py @@ -1,5 +1,5 @@ import os -from typing import Optional, Tuple +from typing import Optional, Tuple, Union from jrdev.file_operations.diff_markup import apply_diff_markup, remove_diff_markup from jrdev.file_operations.diff_utils import create_diff @@ -91,7 +91,7 @@ async def write_file_with_confirmation(app, filepath: str, content: str): return 'no', None -async def write_with_confirmation(app, filepath: str, content: list | str) -> Tuple[str, str]: +async def write_with_confirmation(app, filepath: str, content: Union[list, str]) -> Tuple[str, Optional[str]]: if isinstance(content, list): content_str = ''.join(content) else: