Skip to content

pre-commit additional_dependencies pyjson5 does not work with Flox.dev (Nix) #542

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

Open
vorburger opened this issue Mar 22, 2025 · 1 comment

Comments

@vorburger
Copy link

I'm not sure if this is a problem in this project (https://github.com/python-jsonschema/check-jsonschema) or a more general https://github.com/pre-commit/pre-commit/issues related to https://pre-commit.com/#python (I'm a bit fuzzy on exactly what's what).

At this revision (but it's now about to change, so it will look different at main in a moment) I had this working, originally introduced in enola-dev/enola#960:

  - repo: https://github.com/python-jsonschema/check-jsonschema
    rev: 0.31.1
    hooks:
      - id: check-renovate
        args: ["--verbose"]
        additional_dependencies: ["pyjson5==1.6.7"]

when I was lauching pre-commit in a Python Virtual Environment using my "Linux Fedora System OS Python distro" - like this.

But during enola-dev/enola#1227 for enola-dev/enola#1231, I have (again) run into:

Validate Renovate Config.................................................Failed
- hook id: check-renovate
- exit code: 1

Several files failed to parse.
  BadFileTypeError: cannot parse .renovaterc.json5 because support is missing for json5

  check-jsonschema can only parse json5 files when a json5 parser is installed

  If you are running check-jsonschema as an installed python package, either
      pip install json5
  or
      pip install pyjson5

  If you are running check-jsonschema as a pre-commit hook, set
      additional_dependencies: ['json5']
  or
      additional_dependencies: ['pyjson5']

    in "/home/vorburger/.cache/pre-commit/repoj59hxlnm/py_env-python3.12/lib/python3.12/site-packages/check_jsonschema/instance_loader.py", line 48
    >>> data: t.Any = self._parsers.parse_data_with_path(

and (this time) I can't seem to reliably fix it. Even https://github.com/enola-dev/enola/pull/1233/files to depend on pyjson5 directly in requirements.txt instead of as an additional_dependencies in .pre-commit-config.yaml did not seem to fix it.

I wonder if something in how https://flox.dev/docs/cookbook/languages/python/ (or even Nix itself) isolates Python packages is incompatible with how this (https://github.com/python-jsonschema/check-jsonschema) or https://github.com/pre-commit/pre-commit manages such additional_dependencies.

@vorburger vorburger changed the title pre-commit additional_dependencies pyjson5 does not work with Flox.dev pre-commit additional_dependencies pyjson5 does not work with Flox.dev (Nix) Mar 22, 2025
vorburger added a commit to vorburger/enola that referenced this issue Mar 22, 2025
vorburger added a commit to vorburger/enola that referenced this issue Mar 22, 2025
vorburger added a commit to vorburger/enola that referenced this issue Mar 22, 2025
vorburger added a commit to enola-dev/enola that referenced this issue Mar 22, 2025
@sirosen
Copy link
Member

sirosen commented Mar 22, 2025

Your guesses seem right to me, that someone or something in your stack is isolating or otherwise manipulating the Python environment managed by pre-commit.

additional_dependencies is supposed to be the mechanism for injecting extra packages into the environment. I wouldn't necessarily expect pre-commit to support other methods, but by your example it's not working correctly.

I'll try to help look into this, but I think this is primarily a pre-commit/platform issue.

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

No branches or pull requests

2 participants