Skip to content

Commit

Permalink
chore: add tox and fix tests for py3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldziher committed Jul 18, 2024
1 parent a42a764 commit 37c01ad
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
.pdm-build/
.pdm-python
.pdm.toml
.tox/
.venv/
.vscode/
__pycache__/
Expand Down
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

AI powered Git repository analysis and reporting.

This project is currently in its infancy. The readme will be updated to include more information as the project progresses.
This project is currently in its infancy. The readme will be updated to include more information as the project
progresses.

If you find what you are seeing intriguing, go ahead and ⭐️ the repository to show your support.

Expand All @@ -17,7 +18,7 @@ If you find what you are seeing intriguing, go ahead and ⭐️ the repository t
### Prerequisites

- A compatible python version. It's recommended to use [pyenv](https://github.com/pyenv/pyenv) to manage
python versions.
python versions.
- [pdm](https://github.com/pdm-project/pdm) installed.
- [pre-commit](https://pre-commit.com) installed.
- [hatch](https://hatch.pypa.io) installed,
Expand All @@ -39,15 +40,25 @@ python versions.
### Linting

To lint the codebase, run:

```shell
pdm run lint
```

Tip: You can also run the linters configured in `pyproject.toml` inside your IDE of choice.

### Testing

To run the tests, run:

```shell
pdm run test
```

Tip: You can also run the linters configured in `pyproject.toml` inside your IDE of choice.
#### Tox

To run the tests with `tox`, run:

```shell
pdm run tox
```
4 changes: 2 additions & 2 deletions gitmind/prompts/grade_commit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Final, Literal, TypedDict
from typing import TYPE_CHECKING, Final, Literal, TypedDict, Union

from typing_extensions import override

Expand All @@ -16,7 +16,7 @@
class CommitGradingResult(TypedDict):
"""DTO for grading results."""

grade: int | Literal["NOT_EVALUATED"]
grade: Union[int, Literal["NOT_EVALUATED"]] # noqa: UP007
"""The grade for the commit."""
reason: str
"""The reason for the grade."""
Expand Down
83 changes: 71 additions & 12 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ dev = [
"polyfactory>=2.16.0",
"pytest-logger>=1.1.1",
"types-pygit2>=1.15.0.20240714",
"tox>=4.16.0",
]

[tool.pdm.scripts]
Expand Down
4 changes: 2 additions & 2 deletions tests/caching/file_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ def test_get_or_create_cache_dir_with_non_existing_cache_dir(non_existing_cache_
assert non_existing_cache_dir.exists()


def test_get_or_create_cache_dir_with_none(default_cache_dir: SyncPath) -> None:
async def test_get_or_create_cache_dir_with_none(default_cache_dir: SyncPath) -> None:
path = get_or_create_cache_dir(None)
assert path == default_cache_dir
assert path.exists()
assert await path.exists()


def test_is_idempotent() -> None:
Expand Down
8 changes: 7 additions & 1 deletion tests/prompts/describe_commit_test.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import pytest

from gitmind.exceptions import LLMClientError
from gitmind.llm.base import RetryConfig
from gitmind.prompts import DescribeCommitHandler
from gitmind.prompts.describe_commit import CommitDescriptionResult
from gitmind.utils.commit import CommitMetadata, CommitStatistics
from gitmind.utils.serialization import deserialize
from tests.data_fixtures import describe_commit_response
from tests.helpers import create_mock_client

if TYPE_CHECKING:
from gitmind.utils.commit import CommitMetadata, CommitStatistics


async def test_describe_commit_contents_success_path(commit_data: tuple[CommitStatistics, CommitMetadata, str]) -> None:
mock_client = create_mock_client(return_value=describe_commit_response)
Expand Down
8 changes: 7 additions & 1 deletion tests/prompts/grade_commit_test.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import pytest

from gitmind.exceptions import LLMClientError
from gitmind.llm.base import RetryConfig
from gitmind.prompts import GradeCommitHandler
from gitmind.prompts.grade_commit import CommitGradingResult
from gitmind.rules import DEFAULT_GRADING_RULES
from gitmind.utils.commit import CommitMetadata, CommitStatistics
from tests.data_fixtures import grade_commit_response
from tests.helpers import create_mock_client

if TYPE_CHECKING:
from gitmind.utils.commit import CommitMetadata, CommitStatistics


async def test_grade_commit_success_path(commit_data: tuple[CommitStatistics, CommitMetadata, str]) -> None:
mock_client = create_mock_client(return_value=grade_commit_response)
Expand Down
10 changes: 10 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[tox]
env_list = py{39,310,311,312}

[testenv]
setenv =
PDM_IGNORE_SAVED_PYTHON="1"
deps = pdm
commands =
pdm install
pytest tests

0 comments on commit 37c01ad

Please sign in to comment.