Details
-
Bug
-
Resolution: Done
-
P2: Important
-
6.3.0 Alpha
-
None
-
8d4ba0a8ab (qt/qttools/dev) 8d4ba0a8ab (qt/tqtc-qttools/dev)
Description
Python allows trailing commas inside function calls, and in particular the Black code reformatter adds these trailing commas when breaking long calls up over multiple lines. This is a particular problem for calls to translate(), which are often lengthy. What comes out of Black is something like:
translate( "AddonsInstaller", "Unable to read data from GitHub: check your internet connection and proxy settings and try again.", )
lupdate does not extract this string, because upon seeing the comma after the text, it assumes there will then be a comment. When none is found, it acts as though it is a syntax error and stops the extraction for that line. I believe the same is true if there is a comment but no pluralization.
The problematic line is currently https://code.qt.io/cgit/qt/qttools.git/tree/src/linguist/lupdate/python.cpp#n519
// look for comment if (!match(Tok_Comma) || !matchStringOrNone(comment)) return false;
The logic at currently written is that if there is a comma, there must also be a comment, and if not the extraction failed.