Skip to content

Commit

Permalink
[FIX] attribute-deprecated: Check only 'Model' class' attributes
Browse files Browse the repository at this point in the history
Fix #339
  • Loading branch information
moylop260 committed Sep 8, 2021
1 parent 455ac91 commit dd9b12a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pylint_odoo/checkers/no_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,9 @@ def visit_classdef(self, node):
@utils.check_messages('attribute-deprecated')
def visit_assign(self, node):
node_left = node.targets[0]
if isinstance(node_left, astroid.AssignName):
if (isinstance(node.parent, astroid.ClassDef) and
isinstance(node_left, astroid.AssignName) and
[1 for m in node.parent.basenames if 'Model' in m]):
if node_left.name in self.config.attribute_deprecated:
self.add_message('attribute-deprecated',
node=node_left, args=(node_left.name,))
Expand Down
8 changes: 8 additions & 0 deletions pylint_odoo/test_repo/broken_module/models/broken_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,3 +477,11 @@ def sql_no_injection_private_attributes(self, _variable, variable):
"CREATE VIEW %s AS (SELECT * FROM res_partner)" % _variable)
self._cr.execute(
"CREATE VIEW %s AS (SELECT * FROM res_partner)" % variable)

def func(a):
length = len(a)
return length


class NoOdoo(object):
length = 0

0 comments on commit dd9b12a

Please sign in to comment.