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

Pin Python version for precommit action and update flake8 #7172

Merged
merged 3 commits into from
Oct 16, 2024

Conversation

geographika
Copy link
Member

On pull request branches, the pre-commit/[email protected] is failing. For example here.

It looks like actions/setup-python@v5 requires a Python version to be set as it reports the following warnings:

Warning: Neither 'python-version' nor 'python-version-file' inputs were supplied. Attempting to find '.python-version' file.
Warning: .python-version doesn't exist.
Warning: The `python-version` input is not set.  The version of Python currently in `PATH` will be used.

Errors are then reported in the pre-commit action:

Run python -m pip install pre-commit
  python -m pip install pre-commit
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    RUST_BACKTRACE: 1
    CARGO_TERM_COLOR: always
    CLICOLOR: 1
error: externally-managed-environment

This issue seems to have been reported to https://github.com/pre-commit/action/ several times - most cases are not using setup-python, but some have the same error as the Python version isn't specified - see pre-commit/action#210 (comment)

Switching to Python 3.12 caused the flake8 library to report the errors below. I've updated this to use the latest version of flake8 in the .pre-commit-config.yaml file.

   File "/home/runner/.cache/pre-commit/repoxjhic1i8/py_env-python3.12/lib/python3.12/site-packages/flake8/plugins/manager.py", line 356, in __init__
    self.manager = PluginManager(
                   ^^^^^^^^^^^^^^
  File "/home/runner/.cache/pre-commit/repoxjhic1i8/py_env-python3.12/lib/python3.12/site-packages/flake8/plugins/manager.py", line 238, in __init__
    self._load_entrypoint_plugins()
  File "/home/runner/.cache/pre-commit/repoxjhic1i8/py_env-python3.12/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'

Updating flake8 then causes the following error: ValueError: Error code '#' supplied to 'ignore' option does not match '^[A-Z]{1,3}[0-9]{0,3}$'
This is due to changes in the .flak8 config file format. The GDAL .flake8 file has been updated, so I've updated to the same format: - see OSGeo/gdal#9936

It looks like caching means the pre-commit action is still passing on mapserver/mapserver.
https://github.com/MapServer/MapServer/actions/runs/11366426395/job/31616775459#step:4:61

Cache restored successfully
Cache restored from key: pre-commit-3||dc9c2f1a20b8119bfdb71faa95055d8f2a83bb6aacf921d26e10f90765317698

@geographika
Copy link
Member Author

I think this can be backported to the 8.2 branch too, to avoid failing CI checks in that branch.

@geographika geographika added the backport branch-8-2 To backport a pull request to branch-8-2 label Oct 16, 2024
@geographika geographika merged commit fdb29c9 into MapServer:main Oct 16, 2024
18 checks passed
@geographika geographika deleted the precommit branch October 16, 2024 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport branch-8-2 To backport a pull request to branch-8-2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants