-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Overview
Issue #38 introduced a new configuration object-based API for GitHub operations that reduces parameter complexity while maintaining full backward compatibility. This ticket serves as a reminder to gradually migrate to the new API and establish guidelines for when to replace the old API.
New API Available
The following functions now support configuration object-based APIs:
upsert_pr_comment()- acceptsCommentOperationRequestupsert_issue_comment()- acceptsCommentOperationRequestgenerate_plan_for_issue()- acceptsPlanGenerationRequest
When to Use New API vs Old API
β Use New API When:
- Writing new code - All new functions should use config objects
- Complex parameter combinations - When you need to pass 4+ parameters
- Repeated similar calls - Config objects can be reused across multiple calls
- Unit testing - Config objects make test setup cleaner and more readable
- Adding new features - New functionality should adopt the modern API patterns
- Refactoring existing functions - When touching old code, consider upgrading
π Keep Old API When:
- Simple, one-off calls - For basic operations with 1-2 parameters
- Legacy code that works - Don't change working code unless adding features
- External integrations - If other tools depend on current function signatures
- Performance-critical paths - Old API has slightly less object allocation overhead
Migration Strategy
Phase 1: New Code Only (Current)
- All new functions should use configuration object API
- Leave existing working code unchanged
- Document new API patterns in developer guidelines
Phase 2: Gradual Migration (Future)
Trigger conditions for migration:
- When adding new parameters to existing functions
- When fixing bugs in parameter handling
- When refactoring modules for other reasons
- During major version releases
Phase 3: Deprecation (Far Future)
- Add deprecation warnings to old API (not before v2.0.0)
- Provide migration tools/scripts
- Full removal only in major version bump
Implementation Guidelines
For New Code:
# β
Recommended - New API
config = GitHubOperationConfig(
gh_path="gh",
dry_run=False,
replace_block=True
)
request = CommentOperationRequest(
target_id=pr_number,
body=comment_body,
config=config
)
upsert_pr_comment(request)
# β Avoid for new code - Old API
upsert_pr_comment(pr_number, comment_body, replace_block=True, gh_path="gh", dry_run=False)For Existing Code:
# β
Leave as-is if working
upsert_pr_comment(123, "body", dry_run=True) # Don't change working code
# β
Upgrade when adding features
# If you need to add new parameters or modify behavior, consider upgrading to new APIBenefits of New API
- Reduced parameter complexity - Group related parameters logically
- Better type safety - Full dataclass validation and type checking
- Enhanced extensibility - Easy to add new configuration options
- Improved testing - Config objects are easier to mock and validate
- Better IDE support - Auto-completion for configuration parameters
- Cleaner code - Self-documenting parameter groups
Action Items
- Update developer documentation with API guidelines
- Create examples showing both APIs in README
- Add new API usage to code review checklist
- Consider new API when working on any GitHub operation functions
- Monitor usage patterns and gather feedback
Timeline
- Immediate: Use new API for all new GitHub operation code
- Next 6 months: Gradually migrate high-touch functions when making other changes
- Next year: Evaluate usage patterns and consider deprecation timeline
- Future major version: Potentially deprecate old API (with plenty of notice)
Related
- Closes Reduce Function Parameter Count (PLR0913)Β #38 - Original parameter count reduction issue
- Configuration objects:
autorepro/config/github_ops.py - Refactored functions:
autorepro/pr.py,autorepro/issue.py
Note: This is a reminder/planning ticket. No immediate action required - both APIs work perfectly. Use this as guidance for future development decisions.