Fix tests & move languages.json to framework#56
Conversation
📝 WalkthroughWalkthroughThis PR adds an embedded languages.json resource and registers it via qt_add_resources, updates LanguagesConfiguration to use the resource path (:/languages/resources/languages.json), sets MUSE_LANGUAGES_JSON_PATH for tests and re-enables the Languages_Json correctness test to read that file, updates the CI translation script to read the new languages.json location, and adjusts the Uri_LocalFile unit test to expect an absolute path via io::absoluteFilePath(originPath). 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
eff2d11 to
d507d3e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@buildscripts/ci/translation/s3_packandsend.py`:
- Line 77: Replace the raw open(...) call with a context manager: use "with
open('muse/framework/languages/resources/languages.json', 'r') as
langCode_file:" so the file is automatically closed; update subsequent code that
reads from langCode_file to be inside that with-block and remove the standalone
langCode_file variable (change the mode from "r+" to "r" since the file is only
read).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: cca69427-0fab-4ec6-9def-1cbf4aef469f
📒 Files selected for processing (6)
buildscripts/ci/translation/s3_packandsend.pyframework/languages/CMakeLists.txtframework/languages/internal/languagesconfiguration.cppframework/languages/resources/languages.jsonframework/languages/tests/CMakeLists.txtframework/languages/tests/languagesjson_tests.cpp
|
|
||
| # read languages.json and store language code and name | ||
| langCode_file = open("share/locale/languages.json", "r+") | ||
| langCode_file = open("muse/framework/languages/resources/languages.json", "r+") |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial | ⚡ Quick win
Use a context manager for file handling.
The file is opened without a context manager, which can leave the file handle open if an exception occurs. Python best practice is to use with statements for resource management.
♻️ Proposed fix
-langCode_file = open("muse/framework/languages/resources/languages.json", "r+")
-langCodeNameDict = json.load(langCode_file) # language code --> props
-langCode_file.close()
+with open("muse/framework/languages/resources/languages.json", "r") as langCode_file:
+ langCodeNameDict = json.load(langCode_file) # language code --> propsNote: Changed "r+" to "r" since the file is only read, not modified.
🧰 Tools
🪛 Ruff (0.15.14)
[warning] 77-77: Use a context manager for opening files
(SIM115)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@buildscripts/ci/translation/s3_packandsend.py` at line 77, Replace the raw
open(...) call with a context manager: use "with
open('muse/framework/languages/resources/languages.json', 'r') as
langCode_file:" so the file is automatically closed; update subsequent code that
reads from langCode_file to be inside that with-block and remove the standalone
langCode_file variable (change the mode from "r+" to "r" since the file is only
read).
|
This is slightly disputable, because it forces MuseScore and Audacity to support the same set of languages, while the set of languages supported by MuseScore is far from being a good example (it contains many variants of languages while there are no translators available for those variants, and there may be inconsistencies in the language codes...). |
|
I think it can be interpreted like this:
like |
No description provided.