Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split addonHandler module #17797

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

Split addonHandler module #17797

wants to merge 20 commits into from

Conversation

ctoth
Copy link
Contributor

@ctoth ctoth commented Mar 7, 2025

Link to issue number:

N/A - Code organization improvement

Summary of the issue:

The addonHandler module was overly large with all functionality in init.py, making it difficult to maintain and understand. This PR reorganizes the code into smaller, more focused modules while preserving the same functionality, and adds tests for the AddonBundle component.

Description of user facing changes

None. This is a purely internal refactoring of the codebase with no user-facing changes.

Description of development approach

This PR splits the large addonHandler/__init__.py file into several logical modules:

  • addonBase.py - Contains base classes and common exceptions
  • addon.py - Contains the main Addon class implementation
  • AddonBundle.py - Contains bundle-related functionality
  • AddonManifest.py - Contains manifest-related functionality
  • addonState.py - Manages the state of addons in NVDA

The PR focuses on maintaining functionality while improving code organization. The main additions are unit tests for the AddonBundle functionality, which previously lacked test coverage.

Testing strategy:

  • Added comprehensive unit tests for the AddonBundle module
  • Manually verified that addon functionality still works correctly
  • Ensured that existing tests pass with the new structure

Known issues with pull request:

None

Code Review Checklist:

  • Documentation:
    • Change log entry - N/A (internal code reorganization)
    • User Documentation - N/A (no user-facing changes)
    • Developer / Technical Documentation - Improved through better docstrings
    • Context sensitive help for GUI changes - N/A (no GUI changes)
  • Testing:
    • Unit tests - Added new tests for AddonBundle
    • System (end to end) tests - Existing tests validate the functionality
    • Manual testing - Verified addon installation/management works as before
  • UX of all users considered - N/A (internal refactoring only)
  • API is compatible with existing add-ons - Preserved full API compatibility
  • Security precautions taken - No changes to security model

@coderabbitai summary

ctoth added 16 commits March 6, 2025 09:22
Split addon handling code into separate modules:
- AddonBase.py - Base classes AddonBase and AddonError
- AddonBundle.py - Bundle class for handling addon packages
- AddonManifest.py - Manifest class and manifest handling

This improves code organization by:
- Separating concerns into logical modules
- Reducing complexity of __init__.py

No functional changes, only code reorganization.
Move the Addon class from addonHandler/__init__.py into its own module (addon.py) to improve code organization and readability. Also move AddonStateCategory enum and state management from addonStore/models/status.py to addonHandler/addonState.py where it more logically belongs.

This is a refactoring change that:
- Reduces the size of addonHandler/__init__.py by extracting Addon class
- Places addon state management closer to the addon code
- Improves overall code modularity and organization
Tests cover bundle initialization, validation, extraction, and creation from directories, including various error handling scenarios. Both mocked and real file tests ensure proper functionality with different file types and path formats.
@SaschaCowley
Copy link
Member

@ctoth is this PR ready for review?

@ctoth ctoth closed this Mar 21, 2025
@ctoth ctoth reopened this Mar 21, 2025
@ctoth ctoth marked this pull request as ready for review March 21, 2025 03:47
@ctoth ctoth requested a review from a team as a code owner March 21, 2025 03:47
@ctoth ctoth requested a review from seanbudd March 21, 2025 03:47
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.

3 participants