Skip to main content

subsumes

JSON Schema inclusion for Python: does schema A accept every instance valid under schema B?

If it does, A subsumes B. Use it to check whether a new schema still accepts everything the old schema allowed, such as before you change the schema of stored records or of an API.

pip install subsumes

The package wraps the Rust library of the same name. It needs Python 3.12 or later and has no dependencies.

Usage

from subsumes import No, Unknown, Yes, subsumes

new = {"type": "integer", "minimum": 0}
old = {"type": "integer"}

match subsumes(new, old):
    case Yes():
        print("compatible")
    case No(counterexample):
        print("no longer accepted:", counterexample)  # -1
    case Unknown(reason):
        print("not decided:", reason)

A schema is a Python object as json.load gives it, for JSON Schema draft 2020-12. With Pydantic, that is Model.model_json_schema().

A check returns one of three verdicts:

  • Yes: Every instance valid under B is also valid under A.
  • No: Some instance is valid under B but invalid under A. It carries such an instance as counterexample.
  • Unknown: The library cannot decide. It carries the reason.

A Yes and a No are returned only when certain.

When the library cannot decide

The reason of an Unknown is one of three, and as a string it is a sentence that says why:

  • Unsupported: The answer depends on a construct that the library does not model, such as uniqueItems. Its side is "a" or "b", and its location says where the construct is.
  • Budget: The check ran out of its work budget. A larger one may decide it: subsumes(a, b, budget=100_000_000).
  • Unrepresentable: A does not subsume B, but the library found no counterexample that it can give, such as a number that a float does not hold exactly.

As a condition, Yes is true and No is false. Unknown is neither and raises a TypeError, so a check that is not decided never passes for an answer:

if subsumes(new, old):  # raises when the check is not decided
    print("compatible")

A schema that cannot be checked at all raises a SchemaError, which is a ValueError: it is no schema, it declares another dialect, a keyword has a value that the draft does not allow, or a reference resolves to nothing. A schema has to stand on its own, so one that is spread over several files is bundled into one first.

Regular expressions

A pattern is read as an ECMA-262 regular expression, which is what JSON Schema recommends. For schemas whose patterns are written for the Rust regex crate, as those that Pydantic validates are by default, name that dialect: subsumes(a, b, regex_dialect="rust").

What is modelled

The README of the repository says how patterns, numbers and format are read, and which constructs are not supported.

Metadata

Release files for subsumes 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for subsumes 0.5.0
File Size Uploaded Provenance Actions
subsumes-0.5.0.tar.gz 256.0 kB Without provenance Details for subsumes-0.5.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for subsumes 0.5.0
File Actions
subsumes-0.5.0-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details for subsumes-0.5.0-cp312-abi3-win_amd64.whl
subsumes-0.5.0-cp312-abi3-musllinux_1_2_x86_64.whl CPython 3.12 abi3 Linux musl 1.2+ x86-64 Details for subsumes-0.5.0-cp312-abi3-musllinux_1_2_x86_64.whl
subsumes-0.5.0-cp312-abi3-musllinux_1_2_aarch64.whl CPython 3.12 abi3 Linux musl 1.2+ ARM64 Details for subsumes-0.5.0-cp312-abi3-musllinux_1_2_aarch64.whl
subsumes-0.5.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.12 abi3 Linux glibc 2.17+ x86-64 Details for subsumes-0.5.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
subsumes-0.5.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.12 abi3 Linux glibc 2.17+ ARM64 Details for subsumes-0.5.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
subsumes-0.5.0-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details for subsumes-0.5.0-cp312-abi3-macosx_11_0_arm64.whl
subsumes-0.5.0-cp312-abi3-macosx_10_12_x86_64.whl CPython 3.12 abi3 macOS 10.12+ x86-64 Details for subsumes-0.5.0-cp312-abi3-macosx_10_12_x86_64.whl

Total release size: 7.7 MB

Release files / subsumes-0.5.0.tar.gz

Download URL subsumes-0.5.0.tar.gz
Size 256.0 kB
Tags Source
SHA-256 checksum
How to use checksums
df011597db775f64f44d589deab6ef6f572a03d55e55f94d1e3b9afd25ece9ea
BLAKE2b-256 checksum
How to use checksums
2a8d94687bc98daad19ff078025be59c08a44c2275e2d4be354d81f345abd4cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / subsumes-0.5.0-cp312-abi3-win_amd64.whl

Download URL subsumes-0.5.0-cp312-abi3-win_amd64.whl
Size 864.0 kB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
219ab761e2a6fed156853928a6efc227e254b02d2d172a8acaf2794b8ce62a15
BLAKE2b-256 checksum
How to use checksums
f6fefa8bda861dd36ab9cebe4f4326e487fca8d069069d727346713d4730d997
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / subsumes-0.5.0-cp312-abi3-musllinux_1_2_x86_64.whl

Download URL subsumes-0.5.0-cp312-abi3-musllinux_1_2_x86_64.whl
Size 1.3 MB
Tags CPython 3.12 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
8556349bf01d793dd31d47d59e2bc1f041f3b968fb91b5160f98ce1aee223a3a
BLAKE2b-256 checksum
How to use checksums
7e3c33130feafe552475617cd098c0870e8b0b890e8045079766bb6fe9aa8588
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / subsumes-0.5.0-cp312-abi3-musllinux_1_2_aarch64.whl

Download URL subsumes-0.5.0-cp312-abi3-musllinux_1_2_aarch64.whl
Size 1.2 MB
Tags CPython 3.12 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
ef1d1e470238b6b9d739bb0ba08f858afde192a8f64ca51bf181a7a02906e8bf
BLAKE2b-256 checksum
How to use checksums
a53960f0f605ead87075f7aefbe31cf6cd24d284340d3a2a0da650920b5c3cab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / subsumes-0.5.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL subsumes-0.5.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.1 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
87a5e51fa0a0b3167bade0f717cc06ba83885d2b058b1b95b34be6b162697092
BLAKE2b-256 checksum
How to use checksums
a0cc4c4c5aa6e776b7aa17b000c82278071342d872ef9c903b3d94aaf2e7173e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / subsumes-0.5.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL subsumes-0.5.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.1 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
ae5c170b8a1bed72bac14acb868f083095a3062fcec20e74971e373f7067a5f2
BLAKE2b-256 checksum
How to use checksums
04b8fab04e5d451e70816ae004186f2bc72e0172cce6226abb521416967e5781
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / subsumes-0.5.0-cp312-abi3-macosx_11_0_arm64.whl

Download URL subsumes-0.5.0-cp312-abi3-macosx_11_0_arm64.whl
Size 942.9 kB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4ccf93b5830d28a8b0eb8f9b18e267159eb4756952fed4e6609bcdf1468b68ac
BLAKE2b-256 checksum
How to use checksums
8bad7704033eecefc480b6645c2f96dab0f58ca59b8e7777c6a9d967fec48af2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / subsumes-0.5.0-cp312-abi3-macosx_10_12_x86_64.whl

Download URL subsumes-0.5.0-cp312-abi3-macosx_10_12_x86_64.whl
Size 976.2 kB
Tags CPython 3.12 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
0918cc1ccac6b4ff96759ddadf30a74a69f44e35bb8d31524a3ebc5510e1873f
BLAKE2b-256 checksum
How to use checksums
e551e95cad7e0be92e91f1558ac38fb4e98de20e2a7ec4b7a45a55c5918ca160
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for subsumes 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page