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 subsumes

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

verdict = subsumes(new, old)
if not verdict:
    print("no longer accepted:", verdict.counterexample)  # -1

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 two verdicts:

  • Yes: Every instance valid under B is also valid under A. As a condition it is true.
  • No: Some instance is valid under B but invalid under A. It carries such an instance as counterexample, and as a condition it is false.
from subsumes import No, Yes

match subsumes(new, old):
    case Yes():
        print("compatible")
    case No(counterexample):
        print("no longer accepted:", counterexample)

When the library cannot decide

A Yes and a No are returned only when certain. A check that the library cannot decide raises an UndecidedError, so it never passes for an answer:

  • UnsupportedError: 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.
  • BudgetError: The check ran out of its work budget. A larger one may decide it: subsumes(a, b, budget=100_000_000).
  • UnrepresentableError: 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.
from subsumes import UndecidedError, subsumes

try:
    compatible = bool(subsumes(new, old))
except UndecidedError as undecided:
    print("could not decide:", undecided)

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.3.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.3.0
File Size Uploaded Provenance Actions
subsumes-0.3.0.tar.gz 254.3 kB Without provenance Details for subsumes-0.3.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for subsumes 0.3.0
File Actions
subsumes-0.3.0-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details for subsumes-0.3.0-cp312-abi3-win_amd64.whl
subsumes-0.3.0-cp312-abi3-musllinux_1_2_x86_64.whl CPython 3.12 abi3 Linux musl 1.2+ x86-64 Details for subsumes-0.3.0-cp312-abi3-musllinux_1_2_x86_64.whl
subsumes-0.3.0-cp312-abi3-musllinux_1_2_aarch64.whl CPython 3.12 abi3 Linux musl 1.2+ ARM64 Details for subsumes-0.3.0-cp312-abi3-musllinux_1_2_aarch64.whl
subsumes-0.3.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.3.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
subsumes-0.3.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.12 abi3 Linux glibc 2.17+ ARM64 Details for subsumes-0.3.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
subsumes-0.3.0-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details for subsumes-0.3.0-cp312-abi3-macosx_11_0_arm64.whl
subsumes-0.3.0-cp312-abi3-macosx_10_12_x86_64.whl CPython 3.12 abi3 macOS 10.12+ x86-64 Details for subsumes-0.3.0-cp312-abi3-macosx_10_12_x86_64.whl

Total release size: 7.7 MB

Release files / subsumes-0.3.0.tar.gz

Download URL subsumes-0.3.0.tar.gz
Size 254.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2fc4542919aca66999892467267dd7f4779e3d3efead7612b4646f832d5f2c81
BLAKE2b-256 checksum
How to use checksums
f38a42360bbd4f57e9e9d4ef2e5f980a6201ac375878573c3a241a50fad6dc5b
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.3.0-cp312-abi3-win_amd64.whl

Download URL subsumes-0.3.0-cp312-abi3-win_amd64.whl
Size 859.0 kB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
7eb05da4799892538ada83c2cd5b90c30942f4ab88833c9884d248ed6fb9e9f4
BLAKE2b-256 checksum
How to use checksums
39165d91dd3470757897429d50045f10145ace5ae0cd8142d54d2835f72fe2ef
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.3.0-cp312-abi3-musllinux_1_2_x86_64.whl

Download URL subsumes-0.3.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
d7aca28a5b8c20720f6fbe93851a110c54cac78bea301155199be8f107f2937b
BLAKE2b-256 checksum
How to use checksums
b00c9c8c4924a96ee5ab73e22f9627f2711a264ed3352eb44652b334343fa757
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.3.0-cp312-abi3-musllinux_1_2_aarch64.whl

Download URL subsumes-0.3.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
c9248a3fa8db0719d4815395ca7ab3b1694060866f2b4c75ee292dd52c8f0e9c
BLAKE2b-256 checksum
How to use checksums
8203eb668751791ee9eee7107fa1c57baa8af7771cd99185c1f2bc2d59e04c33
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.3.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL subsumes-0.3.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
f3090417836f4212c0c964f97e82b456c8e68e3aabe4234a3c9e779bb376e8d1
BLAKE2b-256 checksum
How to use checksums
ff0393be7b3191e18d9111471f8995dcd21c801b90dfc9bde0c815f9fe71b73d
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.3.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL subsumes-0.3.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
e9579a15d392cc75c2c5e44a53ecf2fb7a84aab2a14664e6c5b51b701fcca3d6
BLAKE2b-256 checksum
How to use checksums
b38794c547e1ee5743354630e61c6534117df39e6befa90960dfa7b507753bab
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.3.0-cp312-abi3-macosx_11_0_arm64.whl

Download URL subsumes-0.3.0-cp312-abi3-macosx_11_0_arm64.whl
Size 936.4 kB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
572369f83ba534597727b60817dd05b4b73c186093f054548d0d8e0746026ab5
BLAKE2b-256 checksum
How to use checksums
422c9525f8d40d7e5c230d26fffbde7e69a0be4493b79e41e36d73a03709496b
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.3.0-cp312-abi3-macosx_10_12_x86_64.whl

Download URL subsumes-0.3.0-cp312-abi3-macosx_10_12_x86_64.whl
Size 968.5 kB
Tags CPython 3.12 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
1b14db46622b2917a987cc5e9839b34658cb1ae5a5cde4df7a71c04a148d3516
BLAKE2b-256 checksum
How to use checksums
3a04ec81092596d8c2ef0ada84b6662a6272b3e315803ea1e4775099afa4c83f
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.3.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