Refactor codebase with improved error handling, validation, and testing#63
Open
GodsBoy wants to merge 1 commit intoapurvsinghgautam:mainfrom
Open
Refactor codebase with improved error handling, validation, and testing#63GodsBoy wants to merge 1 commit intoapurvsinghgautam:mainfrom
GodsBoy wants to merge 1 commit intoapurvsinghgautam:mainfrom
Conversation
## New Files - `constants.py` - Centralized configuration eliminating code duplication - `tests/` - Unit test suite with pytest (constants, search, scrape, CLI) - `pytest.ini` - Test configuration ## Key Improvements ### Security & Validation - Added input validation for CLI parameters (query length, thread count) - Path traversal protection for output file paths - Removed blanket warning suppression ### Error Handling - Replaced bare `except:` clauses with specific exceptions (Timeout, ConnectionError, RequestException) - Added proper error messages and graceful degradation ### Code Quality - Added type hints to all functions - Comprehensive logging throughout codebase - Removed duplicate USER_AGENTS and Tor config (now in constants.py) - Removed unused function parameters in scrape.py - Fixed duplicate `import re` in llm.py ### Configuration - Externalized Tor settings to environment variables - Added configurable timeouts, worker counts, and limits - Ollama model discovery now cached (5-minute TTL) ### Dependencies - Pinned version ranges in requirements.txt - Added pytest for testing ## Environment Variables Now Supported - TOR_PROXY_HOST, TOR_PROXY_PORT, TOR_CONTROL_PORT - ROBIN_SEARCH_TIMEOUT, ROBIN_SCRAPE_TIMEOUT - ROBIN_MAX_SCRAPE_CHARS, ROBIN_MAX_WORKERS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New Files
constants.py- Centralized configuration eliminating code duplicationtests/- Unit test suite with pytest (constants, search, scrape, CLI)pytest.ini- Test configurationKey Improvements
Security & Validation
Error Handling
except:clauses with specific exceptions (Timeout, ConnectionError, RequestException)Code Quality
import rein llm.pyConfiguration
Dependencies
Environment Variables Now Supported