Skip to content

Update pre-commit hooks to avoid isort installation error #24

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

Merged
merged 1 commit into from
Jul 24, 2024

Conversation

nattylinden
Copy link
Contributor

Hi! When I try to run the configured pre-commit hooks, I get an error:

~/Work/python-llsd $ git log --graph --oneline -1
*   acb55e3 (HEAD -> main, tag: v1.2.4, origin/main, origin/HEAD) Merge pull request #23 from secondlife/signal/fix-array-indent
|\

~/Work/python-llsd $ pre-commit run -a
[INFO] Installing environment for https://github.com/pycqa/isort.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/Users/natty/.cache/pre-commit/repoprmfbeac/py_env-python3/bin/python', '-mpip', 'install', '.')
return code: 1
stdout:
    Processing /Users/natty/.cache/pre-commit/repoprmfbeac
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'done'
      Preparing metadata (pyproject.toml): started
      Preparing metadata (pyproject.toml): finished with status 'error'
stderr:
      error: subprocess-exited-with-error

      × Preparing metadata (pyproject.toml) did not run successfully.
      │ exit code: 1
      ╰─> [17 lines of output]
          Traceback (most recent call last):
            File "/Users/natty/.cache/pre-commit/repoprmfbeac/py_env-python3/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
              main()
            File "/Users/natty/.cache/pre-commit/repoprmfbeac/py_env-python3/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
              json_out['return_val'] = hook(**hook_input['kwargs'])
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/Users/natty/.cache/pre-commit/repoprmfbeac/py_env-python3/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel
              return hook(metadata_directory, config_settings)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/private/var/folders/5b/4fh6_f3n7v92473v7w0zx5400000gp/T/pip-build-env-9r_c1_7f/overlay/lib/python3.12/site-packages/poetry/core/masonry/api.py", line 42, in prepare_metadata_for_build_wheel
              poetry = Factory().create_poetry(Path(".").resolve(), with_groups=False)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/private/var/folders/5b/4fh6_f3n7v92473v7w0zx5400000gp/T/pip-build-env-9r_c1_7f/overlay/lib/python3.12/site-packages/poetry/core/factory.py", line 60, in create_poetry
              raise RuntimeError("The Poetry configuration is invalid:\n" + message)
          RuntimeError: The Poetry configuration is invalid:
            - data.extras.pipfile_deprecated_finder[2] must match pattern ^[a-zA-Z-_.0-9]+$

          [end of output]

      note: This error originates from a subprocess, and is likely not a problem with pip.
    error: metadata-generation-failed

    × Encountered error while generating package metadata.
    ╰─> See above for output.

    note: This is an issue with the package mentioned above, not pip.
    hint: See above for details.
Check the log at /Users/natty/.cache/pre-commit/pre-commit.log

~/Work/python-llsd $

We've seen this in other repositories that have used isort before 5.12.0: since isort doesn't/can't lock the Poetry version used to install it, they ran into an issue where they had put a version stricture in the pipfile_deprecated_finder field, but as of poetry-core 1.5.0 only module names are allowed in that field.

Let's upgrade the pre-commit hooks to the latest released versions with pre-commit autoupdate. This will upgrade isort to a version that can install & run with its currently available dependencies.

These are the current versions as identified by `pre-commit autoupdate`.

To install the isort hook, pre-commit will install whatever the newest
Poetry is. A backward incompatible change in Poetry broke support for
how isort was declaring its "extra" dependency on pip-shims, so existing
isorts became no longer installable. Upgrade the isort hook to 5.12.0+
so we get their pyproject.toml fix:

<PyCQA/isort@0d219a6>

Co-authored-by: Phronimos Linden <40007007+phronimos-linden@users.noreply.github.com>
Copy link

github-actions bot commented Jul 23, 2024

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@nattylinden nattylinden marked this pull request as draft July 23, 2024 18:47
Copy link

codecov bot commented Jul 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.68%. Comparing base (acb55e3) to head (1868e7c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #24      +/-   ##
==========================================
+ Coverage   89.67%   89.68%   +0.01%     
==========================================
  Files           6        6              
  Lines         862      863       +1     
==========================================
+ Hits          773      774       +1     
  Misses         89       89              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nattylinden
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@nattylinden nattylinden marked this pull request as ready for review July 23, 2024 21:45
Copy link
Member

@bennettgoble bennettgoble left a comment

Choose a reason for hiding this comment

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

LGTM, thanks, Natty.

@bennettgoble bennettgoble merged commit ee53c4c into main Jul 24, 2024
11 checks passed
@bennettgoble bennettgoble deleted the nattylinden/pre-commit branch July 24, 2024 15:24
@github-actions github-actions bot locked and limited conversation to collaborators Jul 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants