Skip to content

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

@vorburger

Description

@vorburger

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions