Skip to content

refactor: major code quality and architecture improvements#327

Open
CloudWaddie wants to merge 1 commit intoVeNoMouS:masterfrom
CloudWaddie:master
Open

refactor: major code quality and architecture improvements#327
CloudWaddie wants to merge 1 commit intoVeNoMouS:masterfrom
CloudWaddie:master

Conversation

@CloudWaddie
Copy link

Summary

This PR includes major refactoring and improvements to cloudscraper:

Architecture Refactoring

  • Split monolithic CloudScraper class into focused modules:
    • session_manager.py: Session health, refresh, cookie management
    • request_throttler.py: Rate limiting, concurrency, TLS cipher rotation
    • base.py: Abstract base class for challenge handlers
    • constants.py: Centralized constants

Code Quality Improvements

  • Added comprehensive type hints to all public methods
  • Fixed bare except clauses and empty catches
  • Replaced magic numbers with named constants
  • Pre-compiled regex patterns at module level for performance
  • Removed Python 2 compatibility code
  • Cached browsers.json at initialization to avoid repeated file reads

Testing

  • Expanded test suite from 221 to 567 lines with comprehensive tests

Documentation

  • Rewrote README with clean markdown, better structure and examples

- Split monolithic CloudScraper class into focused modules:
  - session_manager.py: Session health, refresh, cookie management
  - request_throttler.py: Rate limiting, concurrency, TLS cipher rotation
  - base.py: Abstract base class for challenge handlers
  - constants.py: Centralized constants

- Code quality improvements:
  - Added comprehensive type hints to all public methods
  - Fixed bare except clauses and empty catches
  - Replaced magic numbers with named constants
  - Pre-compiled regex patterns at module level
  - Removed Python 2 compatibility code
  - Cached browsers.json at initialization

- Expanded test suite from 221 to 567 lines
- Rewrote README with better documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant