graft

Examples · a real benchmark sync

One change rewritten for a renamed registry, one dropped

lcvisser/jsonschema, a fork of python-jsonschema/jsonschema with 2 changes on commit 61382d7, between releases, synced onto upstream's v4.0.0. Measured 2026-10-28.

Moved onto v4.0.0, tests pass

1 dropped, 1 rewritten. Read by hand afterwards: correct. Rewritten: v4.0.0 renamed the registry meta_schemas to _META_SCHEMAS, and the agent's set_validator_for writes to _META_SCHEMAS, the dict validator_for reads; it also left out the fork's stray 'from re import A', so the second commit (which removed it) came out empty and was dropped. Keeping the old name would raise NameError when called, and no test calls set_validator_for, so the tests could not have caught a wrong rewrite here.

Each change

ChangeOutcomeWhy
Provide utility function to override $schemarewrittenjsonschema/validators.py: The new release still has no way to override the validator chosen from $schema, so set_validator_for is re-added and pointed at the registry's new private name _META_SCHEMAS, and our stray unused `from re import A` import is left out.
Remove accidentally added import.droppedthe new release already contains this change

Tests

pass The project's own tests ran on the carried copy (14.3 s) and on v4.0.0 as shipped (15.7 s), and the changes added no failure.

Agents

1 agent call (90 s): Claude Code (opus, high effort). On Graft, Premium does that work automatically, and your first conflict is free.

The carried diff against v4.0.0

What the pull request would change: the fork's work on top of the new release.

jsonschema/validators.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/jsonschema/validators.py b/jsonschema/validators.pyindex 4ab101c..d6763ba 100644--- a/jsonschema/validators.py+++ b/jsonschema/validators.py@@ -1001,3 +1001,35 @@ def validator_for(schema, default=_LATEST_VERSION):             stacklevel=2,         )     return _META_SCHEMAS.get(schema["$schema"], _LATEST_VERSION)+++def set_validator_for(schema, validator, meta_schema_id=None):+    """+    Register a validator class for the given schema.++    Uses the `$schema` property of the given schema as key in the validator+    lookup table, unless `meta_schema_id` is given to override this.++    This method allows you to set a validator for a particular schema in cases+    where automatic lookup fails, for example when a schema specificies a+    `$schema` that is not resolvable.++    Arguments:++        schema (collections.abc.Mapping):++            the schema to register a validator for++        validator:++            the validator to use for this schema++        meta_schema_id:++            if not `None`, the given value is used as key in the lookup table.+    """+    if meta_schema_id is None:+        meta_schema_id = schema.get("$schema", "")++    if meta_schema_id:+        _META_SCHEMAS[meta_schema_id] = validator

From data/bench/sync-real.json, run with scripts/bench-sync-real.ts on 2026-10-28. Every result on the results page, moved or stayed. Try your own fork.