Skip to content

Fix Python 3.8 type hint compatibility issues#4

Open
jaydotsee wants to merge 4 commits intomainfrom
claude/fix-python-3.8-type-hints-011CV3ihwituYvmxTUQ2R56K
Open

Fix Python 3.8 type hint compatibility issues#4
jaydotsee wants to merge 4 commits intomainfrom
claude/fix-python-3.8-type-hints-011CV3ihwituYvmxTUQ2R56K

Conversation

@jaydotsee
Copy link
Copy Markdown
Owner

  • Replace str | None with Optional[str]
  • Replace dict[str, Any] with Dict[str, Any]
  • Replace dict[str, Any] | None with Optional[Dict[str, Any]]
  • Add Dict and Optional imports from typing module

This resolves the TypeError: unsupported operand type(s) for |: 'type' and 'NoneType' error that occurred when running with Python 3.8.

- Replace `str | None` with `Optional[str]`
- Replace `dict[str, Any]` with `Dict[str, Any]`
- Replace `dict[str, Any] | None` with `Optional[Dict[str, Any]]`
- Add `Dict` and `Optional` imports from typing module

This resolves the TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
error that occurred when running with Python 3.8.
- Change requires-python from >=3.13 to >=3.8 to match CI workflow
- Update ruff target-version from py311 to py38
- Ignore ruff rules UP006, UP007, UP035, UP045 that enforce Python 3.10+ syntax
- These changes ensure consistency between CI tests (3.8 & 3.12) and project config

This resolves the ruff linting failures while maintaining Python 3.8 compatibility.
- Add Dict import from typing module
- Replace dict[str, Any] with Dict[str, Any] in method signatures:
  - display_file_preview() at line 165
  - create_statistics_table() at line 190

This resolves the TypeError: 'type' object is not subscriptable error
during test collection on Python 3.8.
Updated type hints in 14 files to use Python 3.8 compatible syntax:

- src/main.py
- src/modules/backup_manager.py
- src/modules/duplicate_detector.py
- src/modules/enhanced_exif_extractor.py
- src/modules/enhanced_video_extractor.py
- src/modules/exif_extractor.py
- src/modules/file_renamer.py
- src/modules/folder_organizer.py
- src/modules/geolocation.py
- src/modules/image_processor.py
- src/modules/session_detector.py
- src/modules/statistics_generator.py
- src/modules/xmp_analyzer.py
- src/utils/camera_slugger.py

Changes made:
- Replaced dict[X, Y] with Dict[X, Y]
- Replaced list[X] with List[X]
- Replaced set[X] with Set[X]
- Replaced tuple[X, ...] with Tuple[X, ...]
- Replaced X | Y with Union[X, Y]
- Replaced X | None with Optional[X]
- Added necessary typing imports to all files

This completes the Python 3.8 compatibility fixes across the entire project.
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.

2 participants