Daniel Viegas 27de315514 Improve type hints using TYPE_CHECKING pattern
Add TYPE_CHECKING imports and conditional imports for Gramps types:
- Added TYPE_CHECKING to typing imports
- Added conditional imports for Event, Person, Family under TYPE_CHECKING block
- No runtime overhead, only used for type checking

Update TimelineEvent dataclass type hints:
- Changed event: 'Any' to event: 'Event'
- Changed person: Optional['Any'] to person: Optional['Person']
- Maintains forward references with string literals

Update all method parameter type hints:
- _create_timeline_event(): event: 'Event', person_obj: Optional['Person']
- _process_event(): event: 'Event', person_obj: Optional['Person']
- _find_person_for_event(): event: 'Event' -> Optional['Person']
- _get_event_label_text(): event: 'Event', person: Optional['Person']
- _person_matches_handle(): person: Optional['Person']
- _get_family_display_name(): family: 'Family'
- draw_event_label(): event: 'Event', person: Optional['Person']

Update cache dictionary type hint:
- _event_to_person_cache: Dict[str, Optional[Any]] -> Dict[str, Optional['Person']]

Results:
- All Optional[Any] instances replaced with specific Gramps types
- Better IDE autocomplete and type checking support
- Improved code documentation through type hints
- No runtime overhead (TYPE_CHECKING is False at runtime)
- Maintains backward compatibility
2025-11-29 22:40:03 +01:00
Description
MyTimeline Gramps plugin
822 KiB
Languages
Python 94.2%
Shell 5.8%