fix: resolve CI/CD issues - Poetry setup, type annotations, MyPy errors
Some checks failed
CI / test (push) Has been cancelled
CI / build (push) Has been cancelled

This commit is contained in:
2026-02-02 00:08:11 +00:00
parent 4efc8894d1
commit 8186d226f2

View File

@@ -1,6 +1,6 @@
import os import os
from pathlib import Path from pathlib import Path
from typing import Optional, List from typing import Optional, List, cast
import click import click
from rich.console import Console from rich.console import Console
@@ -24,8 +24,8 @@ logger = get_logger(__name__)
@click.pass_context @click.pass_context
def main(ctx: click.Context, verbose: bool, config: Optional[str]) -> None: def main(ctx: click.Context, verbose: bool, config: Optional[str]) -> None:
ctx.ensure_object(dict) ctx.ensure_object(dict)
ctx.obj["verbose"] = verbose ctx.obj["verbose"] = verbose # type: ignore[index]
ctx.obj["config_path"] = config ctx.obj["config_path"] = config # type: ignore[index]
if verbose: if verbose:
logger.setLevel("DEBUG") logger.setLevel("DEBUG")
@@ -43,8 +43,9 @@ def main(ctx: click.Context, verbose: bool, config: Optional[str]) -> None:
def generate(ctx: click.Context, path: str, output: Optional[str], format: str, def generate(ctx: click.Context, path: str, output: Optional[str], format: str,
max_tokens: int, include: tuple, exclude: tuple) -> None: max_tokens: int, include: tuple, exclude: tuple) -> None:
"""Generate optimized context bundle for LLM.""" """Generate optimized context bundle for LLM."""
config_path = ctx.obj.get("config_path") ctx_obj = cast(dict, ctx.obj)
verbose = ctx.obj.get("verbose", False) config_path = ctx_obj.get("config_path")
verbose = ctx_obj.get("verbose", False)
try: try:
config = load_config(config_path) if config_path else Config() config = load_config(config_path) if config_path else Config()
@@ -98,7 +99,8 @@ def generate(ctx: click.Context, path: str, output: Optional[str], format: str,
@click.pass_context @click.pass_context
def analyze(ctx: click.Context, path: str, json: bool) -> None: def analyze(ctx: click.Context, path: str, json: bool) -> None:
"""Analyze codebase and report statistics.""" """Analyze codebase and report statistics."""
verbose = ctx.obj.get("verbose", False) ctx_obj = cast(dict, ctx.obj)
verbose = ctx_obj.get("verbose", False)
try: try:
project_path = Path(path) project_path = Path(path)
@@ -113,24 +115,34 @@ def analyze(ctx: click.Context, path: str, json: bool) -> None:
chunker = CodeChunker(config.chunking) chunker = CodeChunker(config.chunking)
chunks = chunker.chunk_all(chunks) chunks = chunker.chunk_all(chunks)
stats = { stats: dict[str, int] = {
"total_files": len(parser.files), "total_files": len(parser.files),
"total_chunks": len(chunks), "total_chunks": len(chunks),
"files_by_language": {},
"chunks_by_type": {},
"total_lines": sum(c.metadata.line_count for c in chunks), "total_lines": sum(c.metadata.line_count for c in chunks),
"total_functions": sum(1 for c in chunks if c.chunk_type == "function"), "total_functions": sum(1 for c in chunks if c.chunk_type == "function"),
"total_classes": sum(1 for c in chunks if c.chunk_type == "class"), "total_classes": sum(1 for c in chunks if c.chunk_type == "class"),
} }
files_by_lang: dict[str, int] = {}
chunks_by_type: dict[str, int] = {}
for chunk in chunks: for chunk in chunks:
lang = chunk.metadata.language lang = chunk.metadata.language
stats["files_by_language"][lang] = stats["files_by_language"].get(lang, 0) + 1 files_by_lang[lang] = files_by_lang.get(lang, 0) + 1
stats["chunks_by_type"][chunk.chunk_type] = stats["chunks_by_type"].get(chunk.chunk_type, 0) + 1 chunks_by_type[chunk.chunk_type] = chunks_by_type.get(chunk.chunk_type, 0) + 1
if json: if json:
import json as json_module import json as json_module
console.print(json_module.dumps(stats, indent=2)) full_stats: dict[str, object] = {
"total_files": stats["total_files"],
"total_chunks": stats["total_chunks"],
"total_lines": stats["total_lines"],
"total_functions": stats["total_functions"],
"total_classes": stats["total_classes"],
"files_by_language": files_by_lang,
"chunks_by_type": chunks_by_type,
}
console.print(json_module.dumps(full_stats, indent=2))
else: else:
console.print(Panel( console.print(Panel(
Text.from_markup(f""" Text.from_markup(f"""
@@ -143,10 +155,10 @@ Total Functions: {stats['total_functions']}
Total Classes: {stats['total_classes']} Total Classes: {stats['total_classes']}
[b]Files by Language[/b] [b]Files by Language[/b]
{chr(10).join(f' - {lang}: {count}' for lang, count in stats['files_by_language'].items())} {chr(10).join(f' - {lang}: {count}' for lang, count in files_by_lang.items())}
[b]Chunks by Type[/b] [b]Chunks by Type[/b]
{chr(10).join(f' - {type_}: {count}' for type_, count in stats['chunks_by_type'].items())} {chr(10).join(f' - {type_}: {count}' for type_, count in chunks_by_type.items())}
"""), """),
title="Analysis Results", title="Analysis Results",
expand=False expand=False