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

feat: add a schema for validate-pyproject #447

Merged
merged 2 commits into from
Aug 2, 2023
Merged

Conversation

henryiii
Copy link
Collaborator

@henryiii henryiii commented Jul 31, 2023

Adding a schema, generation from our dataclass-based config system, and the expected plugin.

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
@henryiii
Copy link
Collaborator Author

henryiii commented Aug 1, 2023

CC @abravalheri if you'd like to take a look. :)

noxfile.py Outdated Show resolved Hide resolved
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
@henryiii henryiii merged commit 7dd493c into main Aug 2, 2023
36 of 40 checks passed
@henryiii henryiii deleted the henryiii/feat/schema branch August 2, 2023 21:44
@abravalheri
Copy link

abravalheri commented Aug 3, 2023

Sorry for the delay @henryiii.

I had a look on the parts that I have some knowledge (and I admit I skipped the implementation details to generate a JSON schema 😝), but things look fine to me.

Specifically, I believe that "validate_pyproject.tool_schema".scikit-build = "scikit_build_core.settings.skbuild_schema:get_skbuild_schema" should work fine with validate-pyproject.

If you want to add any integration test, something you can try is (ref):

    def test_valid(valid_example: dict):
        validator = validate_pyproject.api.Validator()
        assert validator(valid_example) is not None

    def test_invalid(invalid_example: dict):
        validator = validate_pyproject.api.Validator()
        with pytest.raises(Exception):
            validator(invalid_example)

@abravalheri
Copy link

abravalheri commented Aug 3, 2023

sphinx-jsonschema is the best I could find in the "sphinx space" for JSON schemas, but sometimes it still can be difficult to read/interpret the generated HTML (specially when the level of nesting is high).

There might be better alternatives in the javascript universe, but that is difficult to integrate with sphinx or with pip install1.

If you ever find a different alternative, please let me know.

Footnotes

  1. It there is something I hate doing is setting up a nodejs environment in the CI just to be able to run a couple nodejs-based CLI tools...

henryiii added a commit that referenced this pull request Aug 3, 2023
Followup to #447
based on testing suggestion from @abravalheri.

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
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

Successfully merging this pull request may close these issues.

2 participants