Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct or disable pylint warnings #72

Merged
merged 1 commit into from
May 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion queue_job/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from . import controllers
from . import fields
from . import models
Expand Down
1 change: 0 additions & 1 deletion queue_job/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)


Expand Down
1 change: 0 additions & 1 deletion queue_job/controllers/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015-2016 ACSONE SA/NV (<http://acsone.eu>)
# Copyright 2013-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
Expand Down
1 change: 0 additions & 1 deletion queue_job/exception.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2012-2016 Camptocamp
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

Expand Down
1 change: 0 additions & 1 deletion queue_job/fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# copyright 2016 Camptocamp
# license agpl-3.0 or later (http://www.gnu.org/licenses/agpl.html)

Expand Down
1 change: 0 additions & 1 deletion queue_job/job.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2013-2016 Camptocamp
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

Expand Down
1 change: 0 additions & 1 deletion queue_job/jobrunner/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015-2016 ACSONE SA/NV (<http://acsone.eu>)
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
Expand Down
2 changes: 1 addition & 1 deletion queue_job/jobrunner/channels.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015-2016 ACSONE SA/NV (<http://acsone.eu>)
# Copyright 2015-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
Expand Down Expand Up @@ -114,6 +113,7 @@ class SafeSet(set):
>>> s.remove(1)
"""
def remove(self, o):
# pylint: disable=missing-return,except-pass
try:
super(SafeSet, self).remove(o)
except KeyError:
Expand Down
9 changes: 8 additions & 1 deletion queue_job/jobrunner/runner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015-2016 ACSONE SA/NV (<http://acsone.eu>)
# Copyright 2015-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
Expand Down Expand Up @@ -231,6 +230,10 @@ def __init__(self, db_name):
self._initialize()

def close(self):
# pylint: disable=except-pass
# if close fail for any reason, it's either because it's already closed
# and we don't care, or for any reason but anyway it will be closed on
# del
try:
self.conn.close()
except:
Expand Down Expand Up @@ -277,6 +280,10 @@ def _initialize(self):
cr.execute("LISTEN queue_job")

def select_jobs(self, where, args):
# pylint: disable=sql-injection
# the checker thinks we are injecting values but we are not, we are
# adding the where conditions, values are added later properly with
# parameters
query = ("SELECT channel, uuid, id as seq, date_created, "
"priority, EXTRACT(EPOCH FROM eta), state "
"FROM queue_job WHERE %s" %
Expand Down
29 changes: 0 additions & 29 deletions queue_job/migrations/10.0.1.0.0/pre-migration.py

This file was deleted.

2 changes: 0 additions & 2 deletions queue_job/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# -*- coding: utf-8 -*-

from . import base
from . import queue_job
1 change: 0 additions & 1 deletion queue_job/models/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Camptocamp
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

Expand Down
7 changes: 2 additions & 5 deletions queue_job/models/queue_job.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2013-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

Expand Down Expand Up @@ -53,18 +52,17 @@ class QueueJob(models.Model):
readonly=True, store=True)

state = fields.Selection(STATES,
string='State',
readonly=True,
required=True,
index=True)
priority = fields.Integer()
exc_info = fields.Text(string='Exception Info', readonly=True)
result = fields.Text(string='Result', readonly=True)
result = fields.Text(readonly=True)

date_created = fields.Datetime(string='Created Date', readonly=True)
date_started = fields.Datetime(string='Start Date', readonly=True)
date_enqueued = fields.Datetime(string='Enqueue Time', readonly=True)
date_done = fields.Datetime(string='Date Done', readonly=True)
date_done = fields.Datetime(readonly=True)

eta = fields.Datetime(string='Execute only after')
retry = fields.Integer(string='Current try')
Expand Down Expand Up @@ -252,7 +250,6 @@ class JobChannel(models.Model):

name = fields.Char()
complete_name = fields.Char(compute='_compute_complete_name',
string='Complete Name',
store=True,
readonly=True)
parent_id = fields.Many2one(comodel_name='queue.job.channel',
Expand Down
2 changes: 0 additions & 2 deletions queue_job/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

from . import test_runner_channels
from . import test_runner_runner
from . import test_json_field
1 change: 0 additions & 1 deletion queue_job/tests/common.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# -*- coding: utf-8 -*-
4 changes: 3 additions & 1 deletion queue_job/tests/test_json_field.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# -*- coding: utf-8 -*-
# copyright 2016 Camptocamp
# license agpl-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from datetime import datetime, date
import json

from odoo.tests import common

# pylint: disable=odoo-addons-relative-import
# we are testing, we want to test as we were an external consumer of the API
from odoo.addons.queue_job.fields import JobEncoder, JobDecoder
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's maybe not the place to discuss that, but am I the only with the opinion that tests should run as if they were from the outside, so should use absolute imports rather than relative?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guewen you should put instead this import:

from ..fields import JobEncoder, JobDecoder

That's why pylint complains

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guewen has a point

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any actual case where the relative import would fail?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the point of view of @guewen really relevant.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but with no case, I prefer to be homogeneous across all code, being test or not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should put instead this import:

from ..fields import JobEncoder, JobDecoder

That's why pylint complains

I know, my point is that in tests, I don't want to do that (I do in in addons code for sure).

@pedrobaeza It's not the question of failure, both should work in any case.
It's more a question of what a test is and what the boundaries of the addons are.

If we say that an addon is a library, the tests are definitely not part of this library, they just happen to be in the same folder but they don't belong to the Python package.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I don't find all that conceptual separation needed. As said, I prefer homogeneity, but as always, maintainers decide and this can be raised for a general discussion for removing that check on tests.



Expand Down
3 changes: 2 additions & 1 deletion queue_job/tests/test_runner_channels.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright 2015-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

import doctest
# pylint: disable=odoo-addons-relative-import
# we are testing, we want to test as we were an external consumer of the API
from odoo.addons.queue_job.jobrunner import channels


Expand Down
3 changes: 2 additions & 1 deletion queue_job/tests/test_runner_runner.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright 2015-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

import doctest
# pylint: disable=odoo-addons-relative-import
# we are testing, we want to test as we were an external consumer of the API
from odoo.addons.queue_job.jobrunner import runner


Expand Down
10 changes: 5 additions & 5 deletions queue_job/views/queue_job_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@
<field name="name">queue.job.tree</field>
<field name="model">queue.job</field>
<field name="arch" type="xml">
<tree string="Jobs" create="false"
delete="false"
colors="red:state == 'failed';gray:state == 'done'">
<tree create="false" delete="false"
decoration-danger="state == 'failed'"
decoration-muted="state == 'done'">
<field name="name"/>
<field name="model_name"/>
<field name="state"/>
Expand Down Expand Up @@ -189,7 +189,7 @@
<field name="name">queue.job.channel.tree</field>
<field name="model">queue.job.channel</field>
<field name="arch" type="xml">
<tree string="Channels">
<tree>
<field name="complete_name"/>
</tree>
</field>
Expand Down Expand Up @@ -233,7 +233,7 @@
<field name="name">queue.job.function.tree</field>
<field name="model">queue.job.function</field>
<field name="arch" type="xml">
<tree string="Job Functions" create="false" delete="false">
<tree create="false" delete="false">
<field name="name"/>
<field name="channel_id"/>
</tree>
Expand Down
1 change: 0 additions & 1 deletion queue_job_subscribe/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Cédric Pigeon
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models
1 change: 0 additions & 1 deletion queue_job_subscribe/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Cédric Pigeon
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{'name': 'Queue Job Subscribe',
Expand Down
1 change: 0 additions & 1 deletion queue_job_subscribe/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Cédric Pigeon
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

Expand Down
1 change: 0 additions & 1 deletion queue_job_subscribe/models/queue_job.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Cédric Pigeon
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

Expand Down
1 change: 0 additions & 1 deletion queue_job_subscribe/models/res_users.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Cédric Pigeon
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

Expand Down
1 change: 0 additions & 1 deletion queue_job_subscribe/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Cédric Pigeon
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

Expand Down
1 change: 0 additions & 1 deletion queue_job_subscribe/tests/test_job_subscribe.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Cédric Pigeon
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

Expand Down
1 change: 0 additions & 1 deletion test_queue_job/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
from . import models
1 change: 0 additions & 1 deletion test_queue_job/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

Expand Down
2 changes: 0 additions & 2 deletions test_queue_job/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# -*- coding: utf-8 -*-

from . import test_models
1 change: 0 additions & 1 deletion test_queue_job/models/test_models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

Expand Down
1 change: 0 additions & 1 deletion test_queue_job/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from . import test_job
from . import test_job_channels
from . import test_related_actions
1 change: 0 additions & 1 deletion test_queue_job/tests/test_job.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

Expand Down
1 change: 0 additions & 1 deletion test_queue_job/tests/test_job_channels.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

Expand Down
1 change: 0 additions & 1 deletion test_queue_job/tests/test_related_actions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2014-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

Expand Down