diff --git a/contrib/check-code.py b/contrib/check-code.py index de5a60ea52..5321973eee 100755 --- a/contrib/check-code.py +++ b/contrib/check-code.py @@ -207,8 +207,8 @@ pypats = [ (r'\s<>\s', '<> operator is not available in Python 3+, use !='), (r'^\s*\t', "don't use tabs"), (r'\S;\s*\n', "semicolon"), - (r'[^_]_\((?:"[^"]+"[ \t\n+]*)+%', "don't use % inside _()"), - (r"[^_]_\((?:'[^']+'[ \t\n+]*)+%", "don't use % inside _()"), + (r'[^_]_\([ \t\n]*(?:"[^"]+"[ \t\n+]*)+%', "don't use % inside _()"), + (r"[^_]_\([ \t\n]*(?:'[^']+'[ \t\n+]*)+%", "don't use % inside _()"), (r'(\w|\)),\w', "missing whitespace after ,"), (r'(\w|\))[+/*\-<>]\w', "missing whitespace in expression"), (r'^\s+(\w|\.)+=\w[^,()\n]*$', "missing whitespace in assignment"), diff --git a/tests/test-check-code.t b/tests/test-check-code.t index 14c4109cd9..4be4b15399 100644 --- a/tests/test-check-code.t +++ b/tests/test-check-code.t @@ -255,3 +255,32 @@ warning: add two newlines after '.. note::' [1] + $ cat > ./map-inside-gettext.py < print _("map inside gettext %s" % v) + > + > print _("concatenating " " by " " space %s" % v) + > print _("concatenating " + " by " + " '+' %s" % v) + > + > print _("maping operation in different line %s" + > % v) + > + > print _( + > "leading spaces inside of '(' %s" % v) + > EOF + $ "$check_code" ./map-inside-gettext.py + ./map-inside-gettext.py:1: + > print _("map inside gettext %s" % v) + don't use % inside _() + ./map-inside-gettext.py:3: + > print _("concatenating " " by " " space %s" % v) + don't use % inside _() + ./map-inside-gettext.py:4: + > print _("concatenating " + " by " + " '+' %s" % v) + don't use % inside _() + ./map-inside-gettext.py:6: + > print _("maping operation in different line %s" + don't use % inside _() + ./map-inside-gettext.py:9: + > print _( + don't use % inside _() + [1]