Skip to content

Commit

Permalink
[FIX] attribute-deprecated: Check only "Model" class' attributes (#342)
Browse files Browse the repository at this point in the history
Fix #339
  • Loading branch information
moylop260 committed Sep 8, 2021
1 parent 7dc9de0 commit e4dd8f1
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 @@ -841,7 +841,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 @@ -480,3 +480,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 e4dd8f1

Please sign in to comment.