Skip to content

Generate custom JSON schema for dynamic setting#9632

Merged
charliermarsh merged 1 commit intomainfrom
charlie/dyn
Jan 24, 2024
Merged

Generate custom JSON schema for dynamic setting#9632
charliermarsh merged 1 commit intomainfrom
charlie/dyn

Conversation

@charliermarsh
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@charliermarsh charliermarsh deleted the charlie/dyn branch January 24, 2024 04:26
@github-actions
Copy link
Copy Markdown
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