fix: resolve CI/CD type errors and workflow issues
Some checks failed
CI / test (push) Has been cancelled
CI / build (push) Has been cancelled

This commit is contained in:
2026-02-05 06:48:09 +00:00
parent 58a45aa7bf
commit ce63ec78ea

View File

@@ -1,7 +1,7 @@
import os import os
import sys import sys
from pathlib import Path from pathlib import Path
from typing import Union from typing import Any, Union
import click import click
from rich import print as rprint from rich import print as rprint
@@ -14,25 +14,6 @@ from ..git import install_hook as git_install_hook
from ..llm import OllamaProvider from ..llm import OllamaProvider
@click.group()
@click.option("--config", "-c", type=click.Path(exists=True), help="Path to config file")
@click.option("--endpoint", help="LLM endpoint URL", default=None)
@click.option("--model", "-m", help="Model name to use", default=None)
@click.pass_context
def cli(ctx: click.Context, config: str | None, endpoint: str | None, model: str | None):
ctx.ensure_object(dict)
cfg_path = config or os.environ.get("AICR_CONFIG_PATH")
cfg = get_config(cfg_path)
if endpoint:
cfg.llm.endpoint = endpoint
if model:
cfg.llm.model = model
ctx.obj["config"] = cfg
ctx.obj["repo_path"] = Path.cwd()
@click.group() @click.group()
@click.option("--config", "-c", type=click.Path(exists=True), help="Path to config file") @click.option("--config", "-c", type=click.Path(exists=True), help="Path to config file")
@click.option("--endpoint", help="LLM endpoint URL", default=None) @click.option("--endpoint", help="LLM endpoint URL", default=None)
@@ -59,7 +40,7 @@ def cli(ctx: click.Context, config: str | None, endpoint: str | None, model: str
@click.option("--hook", is_flag=True, help="Run in hook mode (exit non-zero on critical)") @click.option("--hook", is_flag=True, help="Run in hook mode (exit non-zero on critical)")
@click.option("--file", "-f", multiple=True, help="Files to review (default: all staged)") @click.option("--file", "-f", multiple=True, help="Files to review (default: all staged)")
@click.pass_context @click.pass_context
def review( def review( # noqa: PLR0913
ctx: click.Context, ctx: click.Context,
strictness: str | None, strictness: str | None,
output: str, output: str,
@@ -250,9 +231,9 @@ def _get_nested_attr(obj, attr_path: str):
return current return current
def _set_nested_attr(obj, attr_path: str, value: str): def _set_nested_attr(obj, attr_path: str, value: Any) -> None:
parts = attr_path.split(".") parts = attr_path.split(".")
current = obj current: Any = obj
for part in parts[:-1]: for part in parts[:-1]:
if hasattr(current, part): if hasattr(current, part):
current = getattr(current, part) current = getattr(current, part)
@@ -265,11 +246,11 @@ def _set_nested_attr(obj, attr_path: str, value: str):
if getattr(type_hint, "__origin__", None) is Union: if getattr(type_hint, "__origin__", None) is Union:
type_hint = type_hint.__args__[0] type_hint = type_hint.__args__[0]
if hasattr(type_hint, "__name__"): if hasattr(type_hint, "__name__"):
if type_hint.__name__ == "int": if type_hint.__name__ == "int" and isinstance(value, str):
value = int(value) value = int(value)
elif type_hint.__name__ == "float": elif type_hint.__name__ == "float" and isinstance(value, str):
value = float(value) value = float(value)
elif type_hint.__name__ == "bool": elif type_hint.__name__ == "bool" and isinstance(value, str):
value = value.lower() in ("true", "1", "yes") value = value.lower() in ("true", "1", "yes")
setattr(current, final_attr, value) setattr(current, final_attr, value)