Add analyzers, reporters, and utilities
Some checks failed
CI / test (push) Failing after 11s

This commit is contained in:
2026-02-04 14:57:55 +00:00
parent d1ccbceca4
commit 67a4df2c5f

View File

@@ -0,0 +1,35 @@
"""Utility functions for depcheck."""
import os
from pathlib import Path
from typing import Optional
def find_config_file(config_name: str = ".depcheck.yaml") -> Optional[Path]:
"""Find configuration file in current directory or XDG config home."""
current_dir = Path.cwd()
config_path = current_dir / config_name
if config_path.exists():
return config_path
xdg_config = os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config")
xdg_config_path = Path(xdg_config) / "depcheck" / config_name
if xdg_config_path.exists():
return xdg_config_path
return None
def read_file_safe(path: Path) -> Optional[str]:
"""Read file contents safely, return None on error."""
try:
return path.read_text()
except (OSError, IOError):
return None
def parse_version_string(version: str) -> Optional[str]:
"""Clean and normalize a version string."""
version = version.strip()
version = version.lstrip("vV")
return version if version else None