Skip to content

Commit

Permalink
fix_args: add QString to the replacement patterns
Browse files Browse the repository at this point in the history
Plain `QString`s are no more importable because converted to Python
Unicode strings.

Use English in the example
  • Loading branch information
naufraghi committed Oct 19, 2018
1 parent 787ba32 commit 69ef78e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions example-args.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from PyQt4.Qt import (QLabel, qApp)
from PyQt4.Qt import (QLabel, QString, qApp)

class Window(QLabel):
def foo(self, value, tr=None):
self.tr("Messaggio %1").arg(self.getText()) # cose
tr("Messaggio %1 e %2").arg(self.getText()).arg(value)
qApp.translate("Messaggio %1 e %2").arg(self.getText(), value)
self.tr("Message %1").arg(self.getText()) # some comment
tr("Message %1 and %2").arg(self.getText()).arg(value)
qApp.translate("Message %1 and %2").arg(self.getText(), value)
QString("Message %1 and %2").arg(self.getText(), value)
print(tr("Some message %1").arg(value))
2 changes: 1 addition & 1 deletion my_fixes/fix_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FixArgs(fixer_base.BaseFix):
PATTERN = """
power<
before=any*
tr=('tr' | 'translate') trailer< '(' message=any ')' >
tr=('tr' | 'translate' | 'QString') trailer< '(' message=any ')' >
{args}
rest=any*
>
Expand Down

0 comments on commit 69ef78e

Please sign in to comment.