-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 schema and validate-pyproject support #4181
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Some nits and questions below.
}, | ||
"ipynb": { | ||
"type": "boolean", | ||
"description": "Format all input files like Jupyter Notebooks regardless of file extension.This is useful when piping source on standard input.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing the missing space in #4182
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased and picked it up (will push soon).
4b20edf
to
73c6cd3
Compare
@henryiii I fixed a few CI issues but the entry points check appears broken on 3.9 and below:
|
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
6d3a20b
to
275de9a
Compare
5495f06
to
b5a7d07
Compare
diff-shades reporting "Opération was cancelled" is normal? |
It's a known issue, unfortunately. This change is highly unlikely to affect Black's formatting, so I'll merge. Thank you! |
Awesome, thanks!
I would hope so. 😆 I'll make the SchemaStore contribution next & mention this PR. |
Description
This adds a script (Python 3.10+ required) to produce a JSONSchema. I've added it to the package, and provided a helper function / entrypoint to allow validate-pyproject to use it. You can try it out like this:
You can also adjust the tool.black section and see the validation errors. :)
I've also included a
--schemastore
option, which adjusts the output a little for SchemaStore. After this goes in, I'll make a PR to SchemaStore with the schema. The main difference isenable-unstable-feature
is simplified to just be any string. If someone is getting the schema directly from black, then they get the exact enum of options, but SchemaStore is not versioned.Closes #4160.
This goes along with #4178 and doesn't include all the interesting ways to set things that are technically currently supported, like using strings instead of bools and using
_
instead of-
.Checklist - did you ...
CHANGES.md
if necessary?I'll adjust those things after I see how much/little is needed here. I could add (re)generation of the schema file to CI, some tests using validate-pyproject, etc. Or I could remove parts too.
I also realize I forgot to see if this works on Python 3.8, as the importlib logic is different there.