~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
feat: Add pre-commit hook for deprecated settings wrapper detection
LearningCircuit08c283f50c30
diff --git a/.pre-commit-hooks/check-deprecated-settings-wrapper.py b/.pre-commit-hooks/check-deprecated-settings-wrapper.pynew file mode 100755index 0000000000..2e1287788f--- /dev/null+++ b/.pre-commit-hooks/check-deprecated-settings-wrapper.py@@ -0,0 +1,139 @@+#!/usr/bin/env python3+"""+Pre-commit hook to warn about usage of deprecated get_setting_from_db_main_thread wrapper.++This function is deprecated because it's redundant - use the SettingsManager directly+with proper session context management instead.++NOTE: This hook currently only warns about usage to allow gradual migration.+"""++import ast+import sys+from pathlib import Path+from typing import List, Tuple+++def check_file(filepath: Path) -> List[Tuple[int, str]]:+ """Check a single Python file for deprecated wrapper usage.++ Args:+ filepath: Path to the Python file to check++ Returns:+ List of (line_number, error_message) tuples+ """+ errors = []++ try:+ content = filepath.read_text()++ # Check for imports+ if "get_setting_from_db_main_thread" in content:+ lines = content.split("\n")+ for i, line in enumerate(lines, 1):+ if "get_setting_from_db_main_thread" in line:+ if "from" in line and "import" in line:+ errors.append(+ (+ i,+ "Importing deprecated get_setting_from_db_main_thread - use SettingsManager with proper session context",+ )+ )+ elif not line.strip().startswith("#"):+ # Check if it's a function call (not in a comment)+ errors.append(+ (+ i,+ "Using deprecated get_setting_from_db_main_thread - use SettingsManager with get_user_db_session context manager",+ )+ )++ # Also parse the AST to catch any dynamic usage+ try:+ tree = ast.parse(content)+ for node in ast.walk(tree):+ if (+ isinstance(node, ast.Name)+ and node.id == "get_setting_from_db_main_thread"+ ):+ errors.append(+ (+ node.lineno,+ "Reference to deprecated get_setting_from_db_main_thread function",+ )+ )+ except SyntaxError:+ # File has syntax errors, skip AST check+ pass++ except Exception as e:+ print(f"Error checking {filepath}: {e}", file=sys.stderr)++ return errors+++def main():+ """Main entry point for the pre-commit hook."""+ files_to_check = sys.argv[1:]++ if not files_to_check:+ print("No files to check")+ return 0++ all_errors = []++ for filepath_str in files_to_check:+ filepath = Path(filepath_str)++ # Skip non-Python files+ if filepath.suffix != ".py":+ continue++ # Skip the file that defines the function (db_utils.py)+ if filepath.name == "db_utils.py":+ continue++ errors = check_file(filepath)+ if errors:+ all_errors.append((filepath, errors))++ if all_errors:+ print(+ "\n⚠️ Warning: Found usage of deprecated get_setting_from_db_main_thread wrapper:\n"+ )+ print(+ "This function is deprecated and will be removed in a future version."+ )+ print(+ "For Flask routes/views, use SettingsManager with proper session context:\n"+ )+ print(+ " from local_deep_research.database.session_context import get_user_db_session"+ )+ print(+ " from local_deep_research.utilities.db_utils import get_settings_manager"+ )+ print("")+ print(" with get_user_db_session(username) as db_session:")+ print(+ " settings_manager = get_settings_manager(db_session, username)"+ )+ print(" value = settings_manager.get_setting(key, default)")+ print("\nFor background threads, use settings_snapshot pattern.")+ print("\nFiles with deprecated usage:")++ for filepath, errors in all_errors:+ print(f"\n {filepath}:")+ for line_num, error_msg in errors:+ print(f" Line {line_num}: {error_msg}")++ # Return 0 to only warn, not fail+ # Change to return 1 when ready to enforce+ return 0++ return 0+++if __name__ == "__main__":+ sys.exit(main())