Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
# dogfood
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.35.0
rev: 0.36.0
hooks:
- id: check-dependabot
- id: check-github-workflows
Expand All @@ -24,7 +24,7 @@ repos:
- id: check-merge-conflict
- id: trailing-whitespace
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.12.0
rev: 26.1.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
Expand Down
3 changes: 1 addition & 2 deletions scripts/bump-version.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ def update_changelog(new_version):
r"""
Unreleased
----------
(\s*\n)+"""
+ re.escape(vendor_marker),
(\s*\n)+""" + re.escape(vendor_marker),
f"""
Unreleased
----------
Expand Down
1 change: 1 addition & 0 deletions scripts/changelog2md.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

./scripts/changelog2md.py --target 3.20.0
"""

from __future__ import annotations

import argparse
Expand Down
19 changes: 4 additions & 15 deletions scripts/generate-hooks-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,10 @@ def generate_hook_lines(config) -> t.Iterator[str]:
yield " language: python"

if isinstance(config["files"], list):
config["files"] = (
r""">
config["files"] = r""">
(?x)^(
{}
)$""".format(
"|\n ".join(config["files"])
)
)
)$""".format("|\n ".join(config["files"]))

yield f" files: {config['files']}"

Expand Down Expand Up @@ -121,10 +117,7 @@ def update_precommit_usage_supported_hooks() -> None:
content_head = content.split(generated_list_start)[0]
content_tail = content.split(generated_list_end)[-1]

generated_list = "\n\n".join(
[generated_list_start]
+ [
f"""\
generated_list = "\n\n".join([generated_list_start] + [f"""\
``{config["id"]}``
{"~" * (len(config["id"]) + 4)}

Expand All @@ -137,11 +130,7 @@ def update_precommit_usage_supported_hooks() -> None:
rev: {version}
hooks:
- id: {config["id"]}
"""
for config in iter_catalog_hooks()
]
+ [generated_list_end]
)
""" for config in iter_catalog_hooks()] + [generated_list_end])

content = content_head + generated_list + content_tail
with open("docs/precommit_usage.rst", "w") as fp:
Expand Down
2 changes: 1 addition & 1 deletion src/check_jsonschema/formats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_base_format_checker(schema_dialect: str | None) -> jsonschema.FormatChec
# mypy does not consider a class whose instances match a protocol to match
# `type[$PROTOCOL]` so this is considered a mismatch
default_validator_cls: type[jsonschema.Validator] = (
jsonschema.Draft202012Validator # type:ignore[assignment]
jsonschema.Draft202012Validator # type: ignore[assignment]
)
# resolve the dialect, if given, to a validator class
# default to the latest draft
Expand Down
6 changes: 2 additions & 4 deletions tests/acceptance/test_gitlab_reference_handling.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
def test_gitlab_reference_handling_on_bad_data(run_line, tmp_path):
doc = tmp_path / "data.yml"
doc.write_text(
"""\
doc.write_text("""\
include:
- local: setup.yml

Expand All @@ -10,8 +9,7 @@ def test_gitlab_reference_handling_on_bad_data(run_line, tmp_path):
# !reference not a list, error
- !reference .setup
- echo running my own command
"""
)
""")

res = run_line(
[
Expand Down
12 changes: 4 additions & 8 deletions tests/unit/test_instance_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,13 @@ def test_instanceloader_json_data(tmp_path, filename, default_filetype, open_wid
)
def test_instanceloader_yaml_data(tmp_path, filename, default_filetype, open_wide):
f = tmp_path / filename
f.write_text(
"""\
f.write_text("""\
a:
b:
- 1
- 2
c: d
"""
)
""")
loader = InstanceLoader(open_wide(f), default_filetype=default_filetype)
data = list(loader.iter_files())
assert data == [(str(f), {"a": {"b": [1, 2], "c": "d"}})]
Expand Down Expand Up @@ -178,15 +176,13 @@ def test_instanceloader_optional_format_handling(

def test_instanceloader_yaml_dup_anchor(tmp_path, open_wide):
f = tmp_path / "foo.yaml"
f.write_text(
"""\
f.write_text("""\
a:
b: &anchor
- 1
- 2
c: &anchor d
"""
)
""")
loader = InstanceLoader(open_wide(f))
data = list(loader.iter_files())
assert data == [(str(f), {"a": {"b": [1, 2], "c": "d"}})]
Expand Down
15 changes: 4 additions & 11 deletions tests/unit/test_reporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ def test_text_format_success(capsys, verbosity, use_report_result_path):
elif verbosity == 1:
assert captured.out == "ok -- validation done\n"
else:
assert captured.out == textwrap.dedent(
"""\
assert captured.out == textwrap.dedent("""\
ok -- validation done
The following files were checked:
foo.json
"""
)
""")


@pytest.mark.parametrize("verbosity", (0, 1, 2))
Expand Down Expand Up @@ -258,13 +256,8 @@ def test_text_print_parse_error_with_cause(capsys):
# nothing to stderr
assert captured.err == ""
# stdout contains a nicely formatted error
assert (
textwrap.dedent(
"""\
assert textwrap.dedent("""\
Several files failed to parse.
whoopsie during parsing
JSONDecodeError: a bad thing happened: line 1 column 2 (char 1)
"""
)
in captured.out
)
""") in captured.out
12 changes: 4 additions & 8 deletions tests/unit/test_schema_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ def test_schemaloader_remote_path(schemafile):

def test_schemaloader_local_yaml_dup_anchor(tmp_path):
f = tmp_path / "schema.yaml"
f.write_text(
"""
f.write_text("""
---
"$schema": https://json-schema.org/draft/2020-12/schema
type: object
Expand All @@ -115,8 +114,7 @@ def test_schemaloader_local_yaml_dup_anchor(tmp_path):
type: integer
c: &anchor
type: string
"""
)
""")
sl = SchemaLoader(str(f))
schema = sl.get_schema()
assert schema == {
Expand All @@ -136,11 +134,9 @@ def test_schemaloader_local_yaml_dup_anchor(tmp_path):

def test_schemaloader_invalid_yaml_data(tmp_path):
f = tmp_path / "foo.yaml"
f.write_text(
"""\
f.write_text("""\
a: {b
"""
)
""")
sl = SchemaLoader(str(f))
with pytest.raises(SchemaParseError):
sl.get_schema()
Loading