Skip to content

Commit

Permalink
chore: add validate-pyproject-schema-store (#364)
Browse files Browse the repository at this point in the history
* chore: add validate-pyproject-schema-store

Signed-off-by: Henry Schreiner <[email protected]>

* fix: use quotes

Signed-off-by: Henry Schreiner <[email protected]>

* fix: fix hatch def error from validate-pyproject-schema-store

Signed-off-by: Henry Schreiner <[email protected]>

---------

Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii authored Jan 24, 2024
1 parent 0f33f77 commit 4aaa0c4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 26 deletions.
7 changes: 3 additions & 4 deletions docs/_includes/interactive_repo_review.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
<App
header={false}
deps={[
"sp-repo-review==2023.12.21",
"repo-review~=0.10.0",
"validate-pyproject~=0.15.0",
"scikit-build-core~=0.7.0",
"cibuildwheel~=2.16.0",
"sp-repo-review==2023.12.21",
"validate-pyproject-schema-store==2024.1.23",
"validate-pyproject[all]~=0.16.0",
]}
/>,
);
Expand Down
12 changes: 7 additions & 5 deletions docs/pages/guides/style.md
Original file line number Diff line number Diff line change
Expand Up @@ -804,25 +804,27 @@ There are two tools, both based on JSON Schema, that you can use to validate
various configuration files. The first, [validate-pyproject][], validates your
`pyproject.toml` file. By default, it checks the standards-defined sections
(`build-system` and `project`), along with `tool.setuptools`. There are also
plugins for some other tools, like `scikit-build-core` and `cibuildwheel`. Using
it looks like this:
plugins for some other tools, like `scikit-build-core` and `cibuildwheel`. You
can even get all [SchemaStore][]'s plugins with the
[validate-pyproject-schema-store][] plugin. Using it looks like this:

```yaml
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.15
rev: "v0.16"
hooks:
- id: validate-pyproject
additional_dependencies: ["validate-pyproject-schema-store[all]"]
```

You can also validate various other types of files with [check-jsonschema]. It
You can also validate various other types of files with [check-jsonschema][]. It
supports a variety of common files built-in ([see the docs][cjs-common]) like
various CI configuration files. You can also write/provide your own schemas and
validate using those - [SchemaStore][] provides a few hundred different common
schemas, and you can load them via URL. It work on JSON, YAML, and TOML.

```yaml
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.0
rev: "0.27.3"
hooks:
- id: check-dependabot
- id: check-github-workflows
Expand Down
14 changes: 7 additions & 7 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,9 @@ def compare_cruft(session):
re.MULTILINE,
)

PC_REPL_LINE = '''\
PC_REPL_LINE = """\
{2}- repo: {0}
{2} rev: "{1}"'''
{2} rev: {3}{1}{3}"""


GHA_VERS = re.compile(r"[\s\-]+uses: (.*?)@([^\s]+)")
Expand All @@ -375,7 +375,7 @@ def pc_bump(session: nox.Session) -> None:
"""
Bump the pre-commit versions.
"""
session.install("lastversion")
session.install("lastversion>=3.4")
versions = {}
pages = [
Path("docs/pages/guides/style.md"),
Expand All @@ -399,11 +399,11 @@ def pc_bump(session: nox.Session) -> None:
).strip()
new_version = versions[proj]

before = PC_REPL_LINE.format(proj, old_version, space)
after = PC_REPL_LINE.format(proj, new_version, space)
after = PC_REPL_LINE.format(proj, new_version, space, '"')

session.log(f"Bump: {old_version} -> {new_version} ({page})")
txt = txt.replace(before, after)
session.log(f"Bump {proj}: {old_version} -> {new_version} ({page})")
txt = txt.replace(PC_REPL_LINE.format(proj, old_version, space, '"'), after)
txt = txt.replace(PC_REPL_LINE.format(proj, old_version, space, ""), after)

page.write_text(txt)

Expand Down
12 changes: 3 additions & 9 deletions {{cookiecutter.project_name}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,13 @@ repos:
{%- endif %}

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.15
rev: "v0.16"
hooks:
- id: validate-pyproject
{%- if cookiecutter.backend == "skbuild" %}
additional_dependencies:
[scikit-build-core, cibuildwheel, tomli, packaging, trove-classifiers]
{%- elif cookiecutter.__type == "compiled" %}
additional_dependencies:
[cibuildwheel, tomli, packaging, trove-classifiers]
{%- endif %}
additional_dependencies: ["validate-pyproject-schema-store[all]"]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.0
rev: "0.27.3"
hooks:
{%- if cookiecutter.__ci == "github" %}
- id: check-dependabot
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_name}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ version.source = "vcs"
build.hooks.vcs.version-file = "src/{{ cookiecutter.__project_slug }}/_version.py"
{%- endif %}

[tool.hatch.env.default]
[tool.hatch.envs.default]
features = ["test"]
scripts.test = "pytest {args}"

Expand Down

0 comments on commit 4aaa0c4

Please sign in to comment.