Skip to content

Commit

Permalink
chore: fix py3.9 compat issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldziher committed Jul 16, 2024
1 parent 6f03dd1 commit 0517682
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
default_language_version:
python: python3.12
python: python3.9
repos:
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.16.0
Expand Down
4 changes: 2 additions & 2 deletions gitmind/cli/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def get_or_set_cli_context(ctx: Context, **kwargs: Any) -> CLIContext:
ctx.obj = CLIContext(settings=settings, repo=get_or_clone_repository(target_repo))
return cast(CLIContext, ctx.obj)
except ValidationError as e:
field_names = "\n".join([f"-\t{value["loc"][0]}" for value in e.errors()])
field_names = "\n".join([f"-\t{value['loc'][0]}" for value in e.errors()])
raise UsageError(
f"Invalid configuration settings. The following options are required:\n\n{field_names}",
) from e
Expand Down Expand Up @@ -91,7 +91,7 @@ def global_options() -> Callable[[Callable[P, T]], Callable[P, T]]:
options: list[Callable[[Callable[P, T]], Callable[P, T]]] = []

for field_name, field_info in sorted(GitMindSettings.model_fields.items()):
option_param = f"--{field_name.replace("_", "-")}"
option_param = f"--{field_name.replace('_', '-')}"
if isinstance(field_info.annotation, _LiteralGenericAlias):
# we have a generic type and all its args are strings, we can assume this is a Literal - so we can trust that args are choice values
option_type: Choice | type = Choice(list(field_info.annotation.__args__))
Expand Down
4 changes: 2 additions & 2 deletions gitmind/cli/commands/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async def handle_describe(ctx: Context, commit_hash: str) -> CommitDescriptionRe
commit_statistics, commit_metadata, diff = extract_commit_data(repo=cli_ctx["repo"], commit_hex=commit_hash)
debug_echo(
cli_ctx,
f"Retrieved commit {commit_hash}: {commit_metadata["message"]}\n\ncommit_data: {dumps(commit_statistics, indent=2)}",
f"Retrieved commit {commit_hash}: {commit_metadata['message']}\n\ncommit_data: {dumps(commit_statistics, indent=2)}",
)
handler = DescribeCommitHandler(
client=cli_ctx["settings"].llm_client,
Expand Down Expand Up @@ -55,7 +55,7 @@ async def handle_grade(ctx: Context, commit_hash: str) -> dict[str, CommitGradin
commit_statistics, commit_metadata, diff = extract_commit_data(repo=cli_ctx["repo"], commit_hex=commit_hash)
debug_echo(
cli_ctx,
f"Retrieved commit {commit_hash}: {commit_metadata["message"]}\n\ncommit_data: {dumps(commit_statistics, indent=2)}",
f"Retrieved commit {commit_hash}: {commit_metadata['message']}\n\ncommit_data: {dumps(commit_statistics, indent=2)}",
)

handler = GradeCommitHandler(
Expand Down
8 changes: 3 additions & 5 deletions gitmind/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
from pathlib import Path
from re import Pattern
from re import compile as compile_regex
from typing import TYPE_CHECKING, Annotated, Any, Final, Literal
from typing import Annotated, Any, Final, Literal

from pydantic import DirectoryPath, Field, SecretStr, field_validator, model_validator
from pydantic_core import Url # noqa: TCH002
from pydantic_settings import (
BaseSettings,
JsonConfigSettingsSource,
Expand All @@ -17,10 +18,7 @@
YamlConfigSettingsSource,
)

if TYPE_CHECKING:
from pydantic_core import Url

from gitmind.llm.base import LLMClient
from gitmind.llm.base import LLMClient # noqa: TCH001

CONFIG_FILE_NAME: Final[str] = "gitmind-config"

Expand Down
4 changes: 2 additions & 2 deletions gitmind/prompts/describe_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ async def __call__( # type: ignore[override]
Commit description result.
"""
describe_commit_prompt = (
f"**Commit Message**:{metadata["message"]}\n\n"
f"**Commit Message**:{metadata['message']}\n\n"
f"**Commit Statistics**:\n{titleize_commit_statistics(statistics)}\n\n"
f"**Per file breakdown**:\n{serialize(statistics["files_changed"]).decode()}\n\n"
f"**Per file breakdown**:\n{serialize(statistics['files_changed']).decode()}\n\n"
f"**Commit Diff**:\n"
)

Expand Down
2 changes: 1 addition & 1 deletion gitmind/prompts/grade_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async def __call__( # type: ignore[override]

commit_evaluation_prompt = (
f"Evaluate and grade a git commit based on the following criteria:\n{evaluation_instructions}\n\n"
f"**Commit Message**:{metadata["message"]}\n\n"
f"**Commit Message**:{metadata['message']}\n\n"
f"**Commit Diff**:\n{diff}"
)

Expand Down
13 changes: 12 additions & 1 deletion 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 @@ -39,6 +39,7 @@ dependencies = [
"pydantic-settings>=2.3.4",
"pygit2>=1.15.1",
"typing-extensions>=4.12.2",
"eval-type-backport>=0.2.0",
]

[project.urls]
Expand Down

0 comments on commit 0517682

Please sign in to comment.