Skip to content

Commit

Permalink
[REF] test_lint: Add prefer-env-translation lint checker
Browse files Browse the repository at this point in the history
  • Loading branch information
moylop260 committed Jan 13, 2025
1 parent 3a29fcc commit 08f0ec6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion odoo/addons/test_lint/tests/_odoo_checker_gettext.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,20 @@ class OdooBaseChecker(BaseChecker):
'gettext-repr',
'Don\'t use %r to automatically insert quotes in translation strings. Quotes can be different depending on the language: they must be part of the translated string.',
),
'E8506': (
'Better using self.env._',
'prefer-env-translation',
'More info at https://github.com/odoo/odoo/pull/174844',
),
}

@only_required_for_messages('gettext-variable', 'gettext-placeholders', 'gettext-repr')
@only_required_for_messages('gettext-variable', 'gettext-placeholders', 'gettext-repr', 'prefer-env-translation')
def visit_call(self, node):
if isinstance(node.func, astroid.Name):
# direct function call to _
node_name = node.func.name
if node_name == "_":
self.add_message("prefer-env-translation", node=node)
elif isinstance(node.func, astroid.Attribute):
# method call to env._
node_name = node.func.attrname
Expand Down

0 comments on commit 08f0ec6

Please sign in to comment.