[IMP] test-pylint: check for undefined variables

This commit is contained in:
Raphael Collet
2018-05-16 13:58:39 +02:00
parent 96a223a5f0
commit 6a601fe6dc
13 changed files with 22 additions and 17 deletions
@@ -1,3 +1,4 @@
from odoo import api
from odoo.addons.account.tests.account_test_classes import AccountingTestCase
from odoo.tests import tagged
import time
+2 -2
View File
@@ -26,11 +26,11 @@ class ResUsers(models.Model):
# In case we have no value
if not value:
return TRUE_DOMAIN if negative else FALSE_DOMAIN
return expression.TRUE_DOMAIN if negative else expression.FALSE_DOMAIN
if operator in ['in', 'not in']:
if len(value) > 1:
return FALSE_DOMAIN if negative else TRUE_DOMAIN
return expression.FALSE_DOMAIN if negative else expression.TRUE_DOMAIN
if value[0] == 'new':
comp = '!=' if negative else '='
if value[0] == 'active':
+2 -1
View File
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api
from odoo import models, fields, api, _
from odoo.exceptions import UserError
class IrModelFields(models.Model):
+1 -1
View File
@@ -2,7 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models, _
from odoo.exceptions import UserError
from odoo.exceptions import UserError, ValidationError
from odoo.tools.safe_eval import safe_eval
from odoo.addons import decimal_precision as dp
+1 -1
View File
@@ -523,7 +523,7 @@ class Escpos:
if code:
self._raw(code)
else:
raise exception.BarcodeCodeError()
raise BarcodeCodeError()
def receipt(self,xml):
"""
+2 -2
View File
@@ -4,7 +4,7 @@ import base64
from email.utils import formataddr
import re
import uuid
from uuid import uuid4
from odoo import _, api, fields, models, modules, tools
from odoo.exceptions import UserError
@@ -56,7 +56,7 @@ class Channel(models.Model):
('channel', 'Channel')],
'Channel Type', default='channel')
description = fields.Text('Description')
uuid = fields.Char('UUID', size=50, index=True, default=lambda self: '%s' % uuid.uuid4(), copy=False)
uuid = fields.Char('UUID', size=50, index=True, default=lambda self: str(uuid4()), copy=False)
email_send = fields.Boolean('Send messages by email', default=False)
# multi users channel
channel_last_seen_partner_ids = fields.One2many('mail.channel.partner', 'channel_id', string='Last Seen')
+2 -2
View File
@@ -2,7 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from datetime import datetime
import uuid
from uuid import uuid4
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError
@@ -114,7 +114,7 @@ class PosConfig(models.Model):
proxy_ip = fields.Char(string='IP Address', size=45,
help='The hostname or ip address of the hardware proxy, Will be autodetected if left empty.')
active = fields.Boolean(default=True)
uuid = fields.Char(readonly=True, default=lambda self: str(uuid.uuid4()),
uuid = fields.Char(readonly=True, default=lambda self: str(uuid4()),
help='A globally unique identifier for this pos configuration, used to prevent conflicts in client-generated data.')
sequence_id = fields.Many2one('ir.sequence', string='Order IDs Sequence', readonly=True,
help="This sequence is automatically created by Odoo but you can change it "
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models
from odoo import api, models, fields
import logging
+4 -3
View File
@@ -23,9 +23,10 @@ _logger = logging.getLogger(__name__)
class TestPyLint(TransactionCase):
ENABLED_CODES = [
'E0601', # using variable before assignment
'W0123', # eval used
'W0101', # unreachable code
'used-before-assignment',
'undefined-variable',
'eval-used',
'unreachable',
'mixed-indentation',
+2 -1
View File
@@ -1653,7 +1653,8 @@ class Datetime(Field):
# Received data is returned as buffer (in Python 2) or memoryview (in Python 3).
_BINARY = memoryview
if pycompat.PY2:
_BINARY = buffer #pylint: disable=buffer-builtin
#pylint: disable=buffer-builtin,undefined-variable
_BINARY = buffer
class Binary(Field):
type = 'binary'
+2 -1
View File
@@ -21,7 +21,8 @@ if pycompat.PY2:
fp, fname = tools.file_open(path, pathinfo=True)
fp2 = None
if not isinstance(fp, file): # pylint: disable=file-builtin
# pylint: disable=file-builtin,undefined-variable
if not isinstance(fp, file):
# imp.load_source need a real file object, so we create
# one from the file-like object we get from file_open
fp2 = os.tmpfile()
+1 -1
View File
@@ -1139,7 +1139,7 @@ def formatLang(env, value, digits=None, grouping=True, monetary=False, dp=False,
digits = decimal_precision_obj.precision_get(dp)
elif currency_obj:
digits = currency_obj.decimal_places
elif (hasattr(value, '_field') and isinstance(value._field, (float_field, function_field)) and value._field.digits):
elif (hasattr(value, '_field') and getattr(value._field, 'digits', None)):
digits = value._field.digits[1]
if not digits and digits is not 0:
digits = DEFAULT_DIGITS
+1 -1
View File
@@ -13,7 +13,7 @@ PY2 = sys.version_info[0] == 2
_Writer = collections.namedtuple('_Writer', 'writerow writerows')
if PY2:
# pylint: disable=long-builtin,unichr-builtin,unicode-builtin
# pylint: disable=long-builtin,unichr-builtin,unicode-builtin,undefined-variable
unichr = unichr
text_type = unicode
string_types = (str, unicode)