-
Notifications
You must be signed in to change notification settings - Fork 94
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
[IMP] Use specific python version for a set of hooks #282
base: master
Are you sure you want to change the base?
Conversation
Pin the python version per Odoo version. e.g.: as each local environment can be different, force the python version to avoid problems with incompatible hooks versions
ccd5e08
to
b5ae447
Compare
This is a bit problematic, as each Linux distribution may come with a different Python version pre-installed. What if you have Python 3.9 and is compatible, and you force 3.8? Do you have to install (and may get SO conflicts) to get Python 3.8 to run it? I understand that the goal is to avoid the problem if pre-commit for that version doesn't work for example for Python 3.10, but the ideal things is to have a supported Python versions interval. What I don't know is how to perform that. |
I think most experienced Odoo devs know how to simultaneously have multiple versions of Python installed on their machine. This shouldn't be a concern for them. The tricky bit is that lesser-experienced devs may not, and this creates a huge barrier to entry. For me, this barrier to entry makes this PR a non-starter, even though I've often wanted to make the same PR. The way I am currently circumventing this problem is by installing pre-commit in my Odoo virtual environment, which uses a compatible version of Python. This isn't perfect, because when you switch a repo's branch to a different Odoo version, you may be using the wrong virtual environment's pre-commit. |
One example: ruff only supports target version >= 3.7. However, Odoo 13 ran on python 3.6. So we cannot use ruff for formatting an Odoo 13 codebase. Just an example; Ruff didn't exist back then, and i's done in Rust. But anyway I mean that this is something that sooner or later had to happen... At some point, the old pinned pre-commit deps won't be able to run on more modern python interpreters. Another option is to update them, so they do run on them. But even these deps usually deprecate support for deprecated python interpreter versions. Yes, #175 is the definitive solution, so I won't block or push any other solution here 😁 |
@pedrobaeza The problem is that a version of a hook can work for a set of python versions and not another one. So, if you have python3.12 (my case) installed, you should use python3.12 for pre-commit install. In this case, flake8 breaks and does not work. |
Pin the python version per Odoo version.
e.g.: as each local environment can be different, force the python version to avoid problems with incompatible hooks versions
@sbidoul