semgrep: Treat ugettext_lazy like ugettext.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-10-16 17:53:53 -07:00 committed by Tim Abbott
parent f461a64a6b
commit 0be17b6b00
1 changed files with 9 additions and 0 deletions

View File

@ -72,9 +72,17 @@ rules:
pattern-either:
- pattern: django.utils.translation.ugettext(... .format(...))
- pattern: django.utils.translation.ugettext(f"...")
- pattern: django.utils.translation.ugettext_lazy(... .format(...))
- pattern: django.utils.translation.ugettext_lazy(f"...")
severity: ERROR
message: "Format strings after translation, not before"
- id: translated-format-lazy
languages: [python]
pattern: django.utils.translation.ugettext_lazy(...).format(...)
severity: ERROR
message: "Immediately formatting a lazily translated string destroys its laziness"
- id: mutable-default-type
languages: [python]
pattern-either:
@ -116,6 +124,7 @@ rules:
pattern-either:
- pattern: '"..." % ...'
- pattern: django.utils.translation.ugettext(...) % ...
- pattern: django.utils.translation.ugettext_lazy(...) % ...
severity: ERROR
message: "Prefer f-strings or .format for string formatting"