toutatis icon indicating copy to clipboard operation
toutatis copied to clipboard

Refactor core functionality and improve error handling with version bump to 1.32

Open SalvatoreZagaria opened this issue 3 months ago โ€ข 0 comments

This PR introduces several key improvements to the Toutatis codebase:

๐Ÿ”ง Refactoring & Code Structure

  • Refactored main function: Split the original main() function into process_request() for better separation of concerns and improved testability
  • Updated entry point logic: Reorganized script execution flow to follow Python best practices
  • Removed redundant imports: Cleaned up unused imports (argparse moved to appropriate scope, removed unused region_code_for_number)

๐Ÿ›ก๏ธ Enhanced Error Handling

  • Improved JSON parsing: Added robust error handling for API responses with proper null checks
  • Better user not found scenarios: Enhanced detection and handling of missing user data from Instagram API
  • Defensive programming: Added .get() method calls with fallback values to prevent KeyError exceptions
  • Safer data access: Wrapped potentially missing dictionary keys with proper defaults

๐Ÿ“Š Code Quality Improvements

  • More robust parsing logic: Improved handling of user information output with better null safety
  • Cleaner output formatting: Enhanced display logic for optional fields like external URLs, emails, and phone numbers
  • Better variable naming: Used more descriptive variable names (_id instead of id to avoid shadowing builtin)

๐Ÿ“ฆ Version Management

  • Version bump: Updated package version from 1.31 to 1.32 in setup.py

๐Ÿงช Maintainability

  • Improved function organization: Better separation between CLI handling and core processing logic
  • Enhanced readability: More consistent code style and better structured conditional logic

These changes make the codebase more robust, maintainable, and less prone to runtime errors when dealing with varying Instagram API responses.

SalvatoreZagaria avatar Sep 20 '25 09:09 SalvatoreZagaria