python-jsonschema / check-jsonschema

A CLI and set of pre-commit hooks for jsonschema validation with built-in support for GitHub Workflows, Renovate, Azure Pipelines, and more!
https://check-jsonschema.readthedocs.io/en/stable
Other
207 stars 41 forks source link

"unexpected keyword argument 'registry'" when validating specific GitHub workflow #367

Closed l0b0 closed 9 months ago

l0b0 commented 9 months ago

To reproduce:

  1. Install jsonschema 4.20.0
  2. Install check-jsonschema 0.27.1 or 0.27.3 (reproduced with both)
  3. Clone this repo
  4. Run check-jsonschema --builtin-schema=vendor.github-workflows .github/workflows/*.yml

Expected result: Exit code 0, no output.

Actual result:

❯ check-jsonschema --builtin-schema=vendor.github-workflows .github/workflows/*.yml
Error: Unexpected Error building schema validator
TypeError: create.<locals>.Validator.__init__() got an unexpected keyword argument 'registry'
  in "/nix/store/asxk29a77cf1d7kf3pi2arsci81kfi9v-check-jsonschema-0.25.0/lib/python3.11/site-packages/check_jsonschema/checker.py", line 53
  >>> return self._schema_loader.get_validator(
❯ echo $?
1
sirosen commented 9 months ago

Could you share the results of pip freeze in the environment you've built? I wasn't able to reproduce this. My test environment was Linux x86_64 with py 3.11 and

$ pip freeze                                                                        
attrs==23.1.0
certifi==2023.11.17
charset-normalizer==3.3.2
check-jsonschema==0.27.3
click==8.1.7
idna==3.6
jsonschema==4.20.0
jsonschema-specifications==2023.11.2
referencing==0.31.1
regress==0.4.2
requests==2.31.0
rpds-py==0.13.2
ruamel.yaml==0.18.5
ruamel.yaml.clib==0.2.8
urllib3==2.1.0

So this seems to me like a case of some kind of unusual broken environment build.

I notice that the error report says 0.27.1 and 0.27.3, but the error text refers to 0.25.0 . Is that just a discrepancy between various tested versions, or is it a potential indicator that you aren't running the version you intend to run?

l0b0 commented 9 months ago

Could you share the results of pip freeze in the environment you've built?

No, because Nix doesn't use pip, building everything from source.

I notice that the error report says 0.27.1 and 0.27.3, but the error text refers to 0.25.0 . Is that just a discrepancy between various tested versions, or is it a potential indicator that you aren't running the version you intend to run?

:open_mouth: You're right! Turns out I had forgotten about direnv installing check-jsonschema when cd-ing into the project directory, and even if I was running /path/to/nixpkgs/result/bin/check-jsonschema it used the site-packages from direnv in the emergency-management-tools repo.

sirosen commented 9 months ago

Glad you worked it out!

Could you share the results of pip freeze in the environment you've built?

No, because Nix doesn't use pip, building everything from source.

Just for my own edification, is there some equivalent I should ask for when interacting with Nix users? In such cases, I really just want a list of installed packages and their versions. A listing on site-packages would probably work... Is there a site-packages dir?

l0b0 commented 9 months ago

Could you share the results of pip freeze in the environment you've built?

No, because Nix doesn't use pip, building everything from source.

Just for my own edification, is there some equivalent I should ask for when interacting with Nix users? In such cases, I really just want a list of installed packages and their versions. A listing on site-packages would probably work... Is there a site-packages dir?

Actually, I'm wrong. I just have to install pip in the environment (it's not necessary in Nix environments in general), then it does have insight into which packages have been built:

❯ pip freeze
aiodns @ file:///tmp/nix-build-python3.10-aiodns-3.0.0.drv-0/source/dist/aiodns-3.0.0-py3-none-any.whl
aiohttp @ file:///tmp/nix-build-python3.10-aiohttp-3.8.5.drv-0/aiohttp-3.8.5/dist/aiohttp-3.8.5-cp310-cp310-linux_x86_64.whl
[…]