OCA / pylint-odoo

Odoo plugin for Pylint
http://www.pylint.org
138 stars 165 forks source link

Pre-commit check with pylint jobs>1 #491

Open ondrej-kolman opened 1 month ago

ondrej-kolman commented 1 month ago

Module

The name of the module that has a bug. pylint-odoo/checkers/odoo_addons.py

Describe the bug

A clear and concise description of what the bug is.

When running pylint-odoo with pylint configuration with jobs=3 (anything different from jobs=1) than it ends with error

Traceback (most recent call last): File "/usr/lib/python3.11/concurrent/futures/process.py", line 261, in _process_worker r = call_item.fn(*call_item.args, *call_item.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/concurrent/futures/process.py", line 210, in _process_chunk return [fn(args) for args in chunk] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/concurrent/futures/process.py", line 210, in return [fn(*args) for args in chunk] ^^^^^^^^^ File "/home/kolmano/.cache/pre-commit/repoh9417f4h/py_env-python3.11/lib/python3.11/site-packages/pylint/lint/parallel.py", line 79, in _worker_check_single_file _worker_linter.check_single_file_item(file_item) File "/home/kolmano/.cache/pre-commit/repoh9417f4h/py_env-python3.11/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 738, in check_single_file_item with self._astroid_module_checker() as check_astroid_module: File "/usr/lib/python3.11/contextlib.py", line 137, in enter return next(self.gen) ^^^^^^^^^^^^^^ File "/home/kolmano/.cache/pre-commit/repoh9417f4h/py_env-python3.11/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 946, in _astroid_module_checker checker.open() File "/home/kolmano/.cache/pre-commit/repoh9417f4h/py_env-python3.11/lib/python3.11/site-packages/pylint_odoo/checkers/odoo_addons.py", line 650, in open self.linter.config.deprecated_field_parameters = self.colon_list_to_dict( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kolmano/.cache/pre-commit/repoh9417f4h/py_env-python3.11/lib/python3.11/site-packages/pylint_odoo/checkers/odoo_addons.py", line 682, in colon_list_to_dict return dict(item.split(":") for item in colon_list) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: dictionary update sequence element #0 has length 1; 2 is required

To Reproduce

Reproduced on version 9.1.2 and 8.0.20

Steps to reproduce the behavior:

  1. set jobs=3 in .pylintrc configuration file ([MAIN] section)
  2. exec 'pre-commit run --all-files'

Expected behavior Not to raise error

Additional context Tested on ubuntu 22

moylop260 commented 1 month ago

Could you share the output of the following commands, please?

python3 -m pylint --version python3 -c "import pylint_odoo;print(pylint_odoo.__version__)"

moylop260 commented 1 month ago

Could you share the output of the following commands, please?

Forget it, I can reproduced it using the following DockerFile

# docker build -t pylint_jobs_error .
FROM ubuntu:22.04
RUN apt update && \
    apt install -y python3 python3-pip
RUN pip install pylint-odoo

Also, generating the following unittest it is reproduced in the CI:

diff --git a/tests/test_main.py b/tests/test_main.py
index e0cb608..c16e28c 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -144,6 +144,13 @@ class MainTest(unittest.TestCase):
         real_errors = pylint_res.linter.stats.by_msg
         self.assertEqual(self.expected_errors, real_errors)

+    def test_22_jobs(self):
+        """Using jobs could raise new errors"""
+        self.default_extra_params += ["--jobs=2"]
+        pylint_res = self.run_pylint(self.paths_modules, verbose=True)
+        real_errors = pylint_res.linter.stats.by_msg
+        self.assertEqual(self.expected_errors, real_errors)
+