fix: resolve CI/CD issues - Poetry setup, type annotations, MyPy errors
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
from pathlib import Path
|
||||
from typing import List, Optional, Dict, Any
|
||||
from typing import Any, Optional
|
||||
from dataclasses import dataclass, field
|
||||
import yaml
|
||||
|
||||
|
||||
@dataclass
|
||||
class ChunkingConfig:
|
||||
include_patterns: List[str] = field(default_factory=lambda: [
|
||||
include_patterns: list[str] = field(default_factory=lambda: [
|
||||
"*.py", "*.js", "*.ts", "*.go", "*.rs", "*.java", "*.cpp", "*.c", "*.h"
|
||||
])
|
||||
exclude_patterns: List[str] = field(default_factory=lambda: [
|
||||
exclude_patterns: list[str] = field(default_factory=lambda: [
|
||||
"**/test_*.py", "**/__pycache__/**", "**/node_modules/**",
|
||||
"**/.git/**", "**/venv/**", "**/.env/**"
|
||||
])
|
||||
@@ -17,7 +17,7 @@ class ChunkingConfig:
|
||||
min_chunk_size: int = 3
|
||||
preserve_docstrings: bool = True
|
||||
remove_comments: bool = False
|
||||
boilerplate_patterns: List[str] = field(default_factory=lambda: [
|
||||
boilerplate_patterns: list[str] = field(default_factory=lambda: [
|
||||
r"@property\s*\n\s*def\s+\w+\s*\(\s*\)\s*:",
|
||||
r"@abstractmethod",
|
||||
r"@staticmethod",
|
||||
@@ -27,14 +27,14 @@ class ChunkingConfig:
|
||||
|
||||
@dataclass
|
||||
class PrioritizationConfig:
|
||||
keywords: List[str] = field(default_factory=lambda: [
|
||||
keywords: list[str] = field(default_factory=lambda: [
|
||||
"main", "core", "handler", "controller", "service", "model"
|
||||
])
|
||||
size_limit: int = 10000
|
||||
exclude_patterns: List[str] = field(default_factory=lambda: [
|
||||
exclude_patterns: list[str] = field(default_factory=lambda: [
|
||||
"**/test_*.py", "**/*_test.py", "**/conftest.py"
|
||||
])
|
||||
include_only: List[str] = field(default_factory=list)
|
||||
include_only: list[str] = field(default_factory=list)
|
||||
weight_by_depth: bool = True
|
||||
|
||||
|
||||
@@ -51,21 +51,21 @@ class Config:
|
||||
chunking: ChunkingConfig = field(default_factory=ChunkingConfig)
|
||||
prioritization: PrioritizationConfig = field(default_factory=PrioritizationConfig)
|
||||
output: OutputConfig = field(default_factory=OutputConfig)
|
||||
env_overrides: Dict[str, str] = field(default_factory=dict)
|
||||
env_overrides: dict[str, str] = field(default_factory=dict)
|
||||
|
||||
|
||||
def load_config(config_path: Optional[str] = None) -> Config:
|
||||
"""Load configuration from YAML file."""
|
||||
if config_path is None:
|
||||
config_path = Path.cwd() / ".codechunk.yaml"
|
||||
|
||||
config_file = Path(config_path)
|
||||
config_file = Path.cwd() / ".codechunk.yaml"
|
||||
else:
|
||||
config_file = Path(config_path)
|
||||
|
||||
if not config_file.exists():
|
||||
return Config()
|
||||
|
||||
try:
|
||||
with open(config_file, 'r') as f:
|
||||
with open(config_file) as f:
|
||||
data = yaml.safe_load(f)
|
||||
|
||||
if data is None:
|
||||
|
||||
Reference in New Issue
Block a user