mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-07-09 12:41:05 +02:00
## ℹ️ Description Replace the ~115-arm match/case in `__get_message_template` with a module-level `_MESSAGE_TEMPLATES` dict of raw English strings plus a 3-line lazy `_(template)` lookup function. - **Motivation**: Eliminate 5 complexity `noqa` annotations (C901, PLR0911, PLR0912, PLR0915, E701) by removing the real architectural complexity — a pure flat error-code → message mapping that has zero branching or logic. - **Approach**: A `dict[str, str]` of raw English strings (no `_()` calls at import time) with lazy translation inside `__get_message_template`. `"custom_error"` intentionally omitted — handled by `.get()` default. - **Translation**: Caller function name unchanged → translation keys under `__get_message_template` preserved. AST-based translation test extractor updated to recognize `_MESSAGE_TEMPLATES` dict values. ## 📋 Changes Summary - `src/kleinanzeigen_bot/utils/pydantics.py`: Replaced ~115 match arms with `_MESSAGE_TEMPLATES` dict + 3-line function; removed all 5 noqa annotations - `tests/unit/test_translations.py`: Added AST extraction for `_MESSAGE_TEMPLATES` dict values to maintain translation coverage checks ### ⚙️ Type of Change Select the type(s) of change(s) included in this pull request: - [ ] 🐞 Bug fix (non-breaking change which fixes an issue) - [ ] ✨ New feature (adds new functionality without breaking existing usage) - [ ] 💥 Breaking change (changes that might break existing user setups, scripts, or configurations) ## ✅ Checklist Before requesting a review, confirm the following: - [x] I have reviewed my changes to ensure they meet the project's standards. - [x] I have tested my changes and ensured that all tests pass (`pdm run test`). - [x] I have formatted the code (`pdm run format`). - [x] I have verified that linting passes (`pdm run lint`). - [x] I have updated documentation where necessary. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Improved error message handling system to support better internationalization and translation workflows * **Tests** * Updated test suite to extract and verify translatable message strings <!-- end of auto-generated comment: release notes by coderabbit.ai -->