Phase 1 - Quick Wins: - Extract date range calculation to _calculate_date_range() with caching - Extract Y position calculation to _calculate_y_position() - Add remaining constants (TOOLTIP_MAX_WIDTH, LABEL_BACKGROUND_PADDING, LABEL_BACKGROUND_RADIUS) Phase 2 - Refactoring: - Replace tuple indexing with TimelineEvent dataclass for type safety - Break down collect_person_events into smaller methods: * _collect_person_event_refs() * _process_event_ref() * _collect_person_events() - Break down show_tooltip into helper methods: * _format_person_tooltip() * _format_single_event_tooltip() * _get_or_create_tooltip_window() - Break down draw_event_marker into helper methods: * _draw_marker_shadow() * _draw_marker_gradient() - Break down on_draw into helper methods: * _draw_background() * _draw_no_events_message() * _draw_timeline_axis() * _draw_events() Phase 3 - Enhancements: - Add comprehensive type hints to all methods - Improve error handling with specific exceptions (AttributeError, KeyError, ValueError) - Add logging module with appropriate log levels - Improve all docstrings with parameter and return documentation - Reuse tooltip window instead of recreating each time - Improve cache management with hash-based keys instead of context comparison Code Quality Improvements: - Type safety: TimelineEvent dataclass replaces error-prone tuple indexing - Maintainability: Methods are shorter and more focused (28 → 40+ methods) - Performance: Better caching with hash-based keys - Readability: Clear method names and comprehensive docstrings - Debugging: Logging for error tracking - IDE support: Type hints improve autocomplete and error detection All linter errors resolved. Code compiles successfully.
Description
MyTimeline Gramps plugin
Languages
Python
94.2%
Shell
5.8%