OCA / pylint-odoo

Odoo plugin for Pylint
http://www.pylint.org
143 stars 168 forks source link

Support python 3.10 #360

Closed yajo closed 2 years ago

yajo commented 2 years ago

Is your feature request related to a problem? Yes, https://github.com/OCA/oca-addons-repo-template/issues/80 when my local dev env uses python 3.10.

Describe the solution you'd like Add support for python 3.10.

Describe alternatives you've considered Disable this check, install a python 3.9 interpreter.

Additional context isort 5.10.0 added support to python 3.10.

If I apply this diff

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 980193e..58eff0f 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -108,7 +108,7 @@ repos:
           - --exit-zero
         verbose: true
         additional_dependencies:
-          - isort==4.3.21
+          - isort==5.10.1
           - pylint-odoo==3.6.0
       - id: pylint
         name: pylint with mandatory checks
@@ -116,7 +116,7 @@ repos:
           - --valid_odoo_versions=14.0
           - --rcfile=.pylintrc-mandatory
         additional_dependencies:
-          - isort==4.3.21
+          - isort==5.10.1
           - pylint-odoo==3.6.0
   - repo: https://github.com/pre-commit/mirrors-eslint
     rev: v7.8.1

It still fails:

> pre-commit run -a
[INFO] Initializing environment for https://github.com/pycqa/pylint:isort==5.10.1,pylint-odoo==3.6.0.
[INFO] Installing environment for https://github.com/pycqa/pylint.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/var/home/yajo/.cache/pre-commit/repoy5uwlt1_/py_env-python3/bin/python', '-mpip', 'install', '.', 'isort==5.10.1', 'pylint-odoo==3.6.0')
return code: 1
expected return code: 0
stdout:
    Processing /var/home/yajo/.cache/pre-commit/repoy5uwlt1_
      Preparing metadata (setup.py): started
      Preparing metadata (setup.py): finished with status 'done'
    Collecting isort==5.10.1
      Using cached isort-5.10.1-py3-none-any.whl (103 kB)
    Collecting pylint-odoo==3.6.0
      Using cached pylint_odoo-3.6.0-py3-none-any.whl
    Collecting polib==1.1.0
      Using cached polib-1.1.0-py2.py3-none-any.whl (25 kB)
    Collecting restructuredtext-lint==1.3.1
      Using cached restructuredtext_lint-1.3.1-py3-none-any.whl
    Collecting rfc3986
      Using cached rfc3986-2.0.0-py2.py3-none-any.whl (31 kB)
    Collecting whichcraft
      Using cached whichcraft-0.6.1-py2.py3-none-any.whl (5.2 kB)
    Collecting lxml>=4.2.3
      Using cached lxml-4.7.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (6.9 MB)
    Collecting Pygments==2.6.1
      Using cached Pygments-2.6.1-py3-none-any.whl (914 kB)
    Collecting six
      Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
    Collecting pylint-plugin-utils==0.6
      Using cached pylint_plugin_utils-0.6-py3-none-any.whl (10 kB)
    Collecting docutils==0.16
      Using cached docutils-0.16-py2.py3-none-any.whl (548 kB)
    Collecting astroid<=2.5,>=2.4.0
      Using cached astroid-2.5-py3-none-any.whl (220 kB)
    INFO: pip is looking at multiple versions of pylint-odoo to determine which version is compatible with other requirements. This could take a while.
    INFO: pip is looking at multiple versions of <Python from Requires-Python> to determine which version is compatible with other requirements. This could take a while.
    INFO: pip is looking at multiple versions of isort to determine which version is compatible with other requirements. This could take a while.

    The conflict is caused by:
        The user requested isort==5.10.1
        pylint 2.5.3 depends on isort<5 and >=4.2.5

    To fix this you could try to:
    1. loosen the range of package versions you've specified
    2. remove package versions to allow pip attempt to solve the dependency conflict

stderr:
    ERROR: Cannot install isort==5.10.1 and pylint==2.5.3 because these package versions have conflicting dependencies.
    ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies

Check the log at /var/home/yajo/.cache/pre-commit/pre-commit.log
moylop260 commented 2 years ago

Travis still is not supporting python3.10

So I can not set this version in CI in order to reproduce it and auto-tested

Could you check if it is working well without pylint-odoo (only pylint)?

So, it could be an issue in pylint project instead

yajo commented 2 years ago

By updating pylint, with this diff:

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 980193e..24e38f7 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -98,7 +98,7 @@ repos:
         files: /__init__\.py$
         additional_dependencies: ["flake8-bugbear==20.1.4"]
   - repo: https://github.com/pycqa/pylint
-    rev: pylint-2.5.3
+    rev: v2.12.2
     hooks:
       - id: pylint
         name: pylint with optional checks
@@ -108,7 +108,7 @@ repos:
           - --exit-zero
         verbose: true
         additional_dependencies:
-          - isort==4.3.21
+          - isort==5.10.1
           - pylint-odoo==3.6.0
       - id: pylint
         name: pylint with mandatory checks
@@ -116,7 +116,7 @@ repos:
           - --valid_odoo_versions=14.0
           - --rcfile=.pylintrc-mandatory
         additional_dependencies:
-          - isort==4.3.21
+          - isort==5.10.1
           - pylint-odoo==3.6.0
   - repo: https://github.com/pre-commit/mirrors-eslint
     rev: v7.8.1

I get this different error:

[INFO] Initializing environment for https://github.com/pycqa/pylint.
[INFO] Initializing environment for https://github.com/pycqa/pylint:isort==5.10.1,pylint-odoo==3.6.0.
[INFO] Installing environment for https://github.com/pycqa/pylint.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/var/home/yajo/.cache/pre-commit/repon21wux6m/py_env-python3/bin/python', '-mpip', 'install', '.', 'isort==5.10.1', 'pylint-odoo==3.6.0')
return code: 1
expected return code: 0
stdout:
    Processing /var/home/yajo/.cache/pre-commit/repon21wux6m
      Preparing metadata (setup.py): started
      Preparing metadata (setup.py): finished with status 'done'
    Collecting isort==5.10.1
      Using cached isort-5.10.1-py3-none-any.whl (103 kB)
    Collecting pylint-odoo==3.6.0
      Using cached pylint_odoo-3.6.0-py3-none-any.whl
    Collecting rfc3986
      Using cached rfc3986-2.0.0-py2.py3-none-any.whl (31 kB)
    Collecting restructuredtext-lint==1.3.1
      Using cached restructuredtext_lint-1.3.1-py3-none-any.whl
    Collecting docutils==0.16
      Using cached docutils-0.16-py2.py3-none-any.whl (548 kB)
    INFO: pip is looking at multiple versions of <Python from Requires-Python> to determine which version is compatible with other requirements. This could take a while.
    INFO: pip is looking at multiple versions of isort to determine which version is compatible with other requirements. This could take a while.

    The conflict is caused by:
        The user requested pylint 2.12.2 (from /var/home/yajo/.cache/pre-commit/repon21wux6m)
        pylint-odoo 3.6.0 depends on pylint==2.5.3; python_version >= "3"

    To fix this you could try to:
    1. loosen the range of package versions you've specified
    2. remove package versions to allow pip attempt to solve the dependency conflict

stderr:
    ERROR: Cannot install pylint 2.12.2 (from /var/home/yajo/.cache/pre-commit/repon21wux6m) and pylint-odoo==3.6.0 because these package versions have conflicting dependencies.
    ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies

Check the log at /var/home/yajo/.cache/pre-commit/pre-commit.log

Quoting from https://iscinumpy.dev/post/bound-version-constraints/ (go to the tl;dr of the tl;dr 😆):

Libraries/packages should be setting a floor, and if necessary excluding known buggy versions, but otherwise don’t cap the maximum version as you can’t predict future compatibility

So maybe we should just do that here and hope for the best. What do you think?

pedrobaeza commented 2 years ago

@yajo your solution at https://github.com/moduon/oca-addons-repo-template/commit/46b3b70ec0144b4fb047559b238001107c0be74d works for both old Pythons and new? Can be proposed to the main repo?

moylop260 commented 2 years ago

@yajo

Travis already enabled the py3.10 and even py3.11

I just have created the following PR:

moylop260 commented 2 years ago

FYI the CI is installing correctly the package for py3.10 even py3.11

Could you try using the hook of pylint-odoo directly instead of pylint, please?

More info:

yajo commented 2 years ago

Done, see https://github.com/OCA/oca-addons-repo-template/pull/149.

moylop260 commented 1 year ago

@yajo

FYI now we are supporting 3.11 too from github actions: