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

Default Ruff configuration file reports schema error #9630

Closed
ssteinerx opened this issue Jan 23, 2024 · 5 comments · Fixed by #9632
Closed

Default Ruff configuration file reports schema error #9630

ssteinerx opened this issue Jan 23, 2024 · 5 comments · Fixed by #9632
Assignees
Labels
bug Something isn't working

Comments

@ssteinerx
Copy link

Ruff config gives a .toml file that is equivalent to the default configuration.

Even Better TOML reports an error in that .toml file:

{"quote-style":"double","indent-style":"space","skip-magic-trailing-comma":false,"line-ending":"auto","docstring-code-format":false,"docstring-code-line-length":"dynamic"} is not valid under any of the given schemas

I reported this in the .toml validator used by Even Better TOML: Taplo issue tracker #536 and they tell me the .toml file does not match the schema and that:

this is not a problem in Taplo but in the Ruff schema.

and that there's an issue for this in SchemaStore.

I couldn't find another issue here about it, so here one is.

@charliermarsh charliermarsh added the bug Something isn't working label Jan 24, 2024
@charliermarsh charliermarsh self-assigned this Jan 24, 2024
@charliermarsh
Copy link
Member

Thanks -- let me check if the schema is out-of-date. We have to update it manually and it sometimes slips through the cracks during releases.

@charliermarsh
Copy link
Member

The PR is here: SchemaStore/schemastore#3549. But I don't expect any of those to fix the specific error you're reporting, those settings were added long ago. Let me try in VS Code.

@charliermarsh
Copy link
Member

It seems like the format section isn't being picked up by the extension. But the schema file looks right to me on our side. Hmm...

@charliermarsh
Copy link
Member

Ah, I see, it's specifically this line:

# 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"

@charliermarsh
Copy link
Member

Thanks for reporting this, should be fixed by #9632.

charliermarsh added a commit that referenced this issue 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](https://github.com/astral-sh/ruff/assets/1309177/7b4ea6e8-07db-4590-bd1e-73a01a35d747)

It seems like the issue is with:

```toml
# 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](https://github.com/astral-sh/ruff/assets/1309177/ab7809d4-b077-44e9-8f98-ed893aaefe5d)

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

Closes #9630.
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 a pull request may close this issue.

2 participants