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

Generate custom JSON schema for dynamic setting #9632

Merged
merged 1 commit into from
Jan 24, 2024
Merged

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Jan 24, 2024

Summary

If you paste in the TOML for our default configuration (from the docs), it's rejected by our JSON Schema:

Screenshot 2024-01-23 at 10 08 09 PM

It seems like the issue is with:

# Set the line length limit used when formatting code snippets in
# docstrings.
#
# This only has an effect when the `docstring-code-format` setting is
# enabled.
docstring-code-line-length = "dynamic"

Specifically, since that value uses a custom Serde implementation, I guess Schemars bails out? This PR adds a custom representation to allow "dynamic" (but no other strings):

Screenshot 2024-01-23 at 10 27 21 PM

This seems like it should work but I don't have a great way to test it.

Closes #9630.

@charliermarsh charliermarsh added the bug Something isn't working label Jan 24, 2024
@charliermarsh
Copy link
Member Author

Oh actually, I was able to test it with https://www.jsonschemavalidator.net/.

Valid integer:

Screenshot 2024-01-23 at 10 33 26 PM

Valid string:

Screenshot 2024-01-23 at 10 33 32 PM

Invalid string:

Screenshot 2024-01-23 at 10 33 29 PM

Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

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

Thank you. :-)

@charliermarsh
Copy link
Member Author

No prob!

@charliermarsh charliermarsh enabled auto-merge (squash) January 24, 2024 04:20
@charliermarsh charliermarsh merged commit b0d6fd7 into main Jan 24, 2024
16 checks passed
@charliermarsh charliermarsh deleted the charlie/dyn branch January 24, 2024 04:26
Copy link
Contributor

ruff-ecosystem results

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default Ruff configuration file reports schema error
2 participants