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

[FIX][15.0] branches Update flake8 autoflake #243

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

bosd
Copy link
Contributor

@bosd bosd commented Jan 13, 2024

Fixes 15.0 branches:

As spotted in 15.0 branch of https://github.com/OCA/stock-logistics-warehouse/tree/15.0
job: https://github.com/OCA/stock-logistics-warehouse/actions/runs/6711504373/job/18239016420
CI on 15.0 PR are red.

autoflake

Traceback (most recent call last):
  File "/home/bosd/.cache/pre-commit/repop6v3fone/py_env-python3/bin/autoflake", line 5, in <module>
    from autoflake import main
  File "/home/bosd/.cache/pre-commit/repop6v3fone/py_env-python3/lib/python3.12/site-packages/autoflake.py", line 32, in <module>
    import distutils.sysconfig
ModuleNotFoundError: No module named 'distutils'

flake8

Traceback (most recent call last):
  File "/home/bosd/.cache/pre-commit/repo1vkztq8l/py_env-python3/bin/flake8", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/bosd/.cache/pre-commit/repo1vkztq8l/py_env-python3/lib/python3.12/site-packages/flake8/main/cli.py", line 22, in main
    app.run(argv)
  File "/home/bosd/.cache/pre-commit/repo1vkztq8l/py_env-python3/lib/python3.12/site-packages/flake8/main/application.py", line 363, in run
    self._run(argv)
  File "/home/bosd/.cache/pre-commit/repo1vkztq8l/py_env-python3/lib/python3.12/site-packages/flake8/main/application.py", line 350, in _run
    self.initialize(argv)
  File "/home/bosd/.cache/pre-commit/repo1vkztq8l/py_env-python3/lib/python3.12/site-packages/flake8/main/application.py", line 330, in initialize
    self.find_plugins(config_finder)
  File "/home/bosd/.cache/pre-commit/repo1vkztq8l/py_env-python3/lib/python3.12/site-packages/flake8/main/application.py", line 153, in find_plugins
    self.check_plugins = plugin_manager.Checkers(local_plugins.extension)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bosd/.cache/pre-commit/repo1vkztq8l/py_env-python3/lib/python3.12/site-packages/flake8/plugins/manager.py", line 356, in __init__
    self.manager = PluginManager(
                   ^^^^^^^^^^^^^^
  File "/home/bosd/.cache/pre-commit/repo1vkztq8l/py_env-python3/lib/python3.12/site-packages/flake8/plugins/manager.py", line 238, in __init__
    self._load_entrypoint_plugins()
  File "/home/bosd/.cache/pre-commit/repo1vkztq8l/py_env-python3/lib/python3.12/site-packages/flake8/plugins/manager.py", line 254, in _load_entrypoint_plugins
    eps = importlib_metadata.entry_points().get(self.namespace, ())
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'EntryPoints' object has no attribute 'get'


@pedrobaeza
Copy link
Member

Please put a link to a CI job with such problem.

@bosd
Copy link
Contributor Author

bosd commented Jan 13, 2024

Copy link
Member

@zamberjo zamberjo left a comment

Choose a reason for hiding this comment

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

This Pr fixes #257

Copy link

@Dranyel-Bosd Dranyel-Bosd left a comment

Choose a reason for hiding this comment

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

LGTM 👍♥️

@pedrobaeza
Copy link
Member

The referred PR was merged, so isn't this something specific on your side due to newer Python?

@OCA-git-bot
Copy link

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@bosd
Copy link
Contributor Author

bosd commented May 10, 2024

I assume you're referring to this:
In that pr I did a manual overwrite.

Repo template may need update as well. #243

Originally posted by @bosd in OCA/stock-logistics-warehouse#1913 (comment)

@zamberjo
Copy link
Member

This is unnecessary, updating maintainer-tools to f81a2cd8b3e7ba06d96a6fc8c944e6c7174faf7f will fix it:
OCA/maintainer-tools#618

em230418 added a commit to em230418/misc-addons that referenced this pull request Oct 14, 2024
@florian-dacosta
Copy link

Hello,
The problem exists and it does not depend on Odoo's version, so we would need to update the flake8 for Odoo version < 15 as well.

The problem happends when you run pre-commit with an up-to-date python version (python 3.12 in my case) as it is not compatible with flake8 3.9.2
It depends on the python version of the host running pre-commit.
We do not see it on the CI because the CI runs on older python version for Odoo < 18
And for odoo 18, there is not flake 3.9.2...

I have this issue for almost all OCA repo for version 14, 16...
@sbidoul

@bosd
Copy link
Contributor Author

bosd commented Nov 14, 2024

Should we merge this?
We have one person who doesn't need it. But others approving the pr and say it is needed.

@florian-dacosta
Copy link

florian-dacosta commented Nov 14, 2024

@bosd Can you rebase to resolve the conflict ?
I believe the flake8 version should also be updated in this part
{%- if odoo_version < 15 %}

@bosd
Copy link
Contributor Author

bosd commented Nov 14, 2024

@florian-dacosta Done. Rebased and added the update for <v15

@bosd
Copy link
Contributor Author

bosd commented Nov 14, 2024

just force pushed again. Because actions is/was adding a test it cannot complete.
image

@bosd
Copy link
Contributor Author

bosd commented Nov 15, 2024

Indeed this pr is still needed as in: OCA/sale-workflow#3411

@sbidoul
Copy link
Member

sbidoul commented Nov 15, 2024

The risk with this PR is that the new flake8 version will have new rules that make existing branches red on many repos. That is why we pin the versions of the hooks.

The other approach is to set the python version in the pre-commit config (something like #282) but then devs need to install multiple python versions. This is my personal preference, because nowadays it is easier and faster than ever to install different python versions with tools such as mise or uv.

And there is also the nix approach which I have not evaluated in details. The drawback of that one is that it seems to be more complex to setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants