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.4.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.4.0
File Size Uploaded Provenance Actions
subsumes-0.4.0.tar.gz 254.7 kB Without provenance Details for subsumes-0.4.0.tar.gz

Built distributions (wheels)

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

Total release size: 7.7 MB

Release files / subsumes-0.4.0.tar.gz

Download URL subsumes-0.4.0.tar.gz
Size 254.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8c62f2635b014a19464f75ff9d94147e561546e1c264f08c8ad7177367a0f69c
BLAKE2b-256 checksum
How to use checksums
67ae42ba030b702bc56ff6f52dbf8298976c313deba098779eb66e616db859ef
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.4.0-cp312-abi3-win_amd64.whl

Download URL subsumes-0.4.0-cp312-abi3-win_amd64.whl
Size 858.6 kB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
f4f409d82838178ca4945af992bc5615575946ea239656f2686c46b1d7c19d90
BLAKE2b-256 checksum
How to use checksums
fac9ec7d04fccca8cbffaff188bdb1cd0836a89bb91ee3cdaae6255ad005fe61
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.4.0-cp312-abi3-musllinux_1_2_x86_64.whl

Download URL subsumes-0.4.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
1c86ae11dc45643d2bc1f304826287940a507851e74c7e182dc82c582623488d
BLAKE2b-256 checksum
How to use checksums
40bed1e1bef7a8c02ac50c304372d179e4957cfa39ef5e5f2af865ba01a075fb
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.4.0-cp312-abi3-musllinux_1_2_aarch64.whl

Download URL subsumes-0.4.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
a54146eea7af930ed59da1aff7897498f70a1d2afcc6e85b36e5323ce6b38124
BLAKE2b-256 checksum
How to use checksums
e2ed2a7051c97935293b14436f753b37797879f0fdad346a3e287d80d93b4bd4
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.4.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL subsumes-0.4.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
1f9d148ae9aeac71017b442e53440fd1b675424c9e9d7f3037983b892edd993a
BLAKE2b-256 checksum
How to use checksums
5a57622c179ad9b67946646dd9c7d5ed2bc44308877411979a28606754da57e7
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.4.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL subsumes-0.4.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
4228d87738bf62849bccc3dae5d6ba7355fabe64b4f5a80960df811bcc8331da
BLAKE2b-256 checksum
How to use checksums
26d2a7901c00d3de6db8daaee81bbe991d607028c836a74dcac5a544e23f56f3
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.4.0-cp312-abi3-macosx_11_0_arm64.whl

Download URL subsumes-0.4.0-cp312-abi3-macosx_11_0_arm64.whl
Size 937.9 kB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
716d60e24f3d1808b1f85d9ff96a818499a3ec646561ad2cb1f9a0f345555c2d
BLAKE2b-256 checksum
How to use checksums
a0ef7ff51d619d589b961613537c076eef795217073b275facff8592da9b335f
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.4.0-cp312-abi3-macosx_10_12_x86_64.whl

Download URL subsumes-0.4.0-cp312-abi3-macosx_10_12_x86_64.whl
Size 971.2 kB
Tags CPython 3.12 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
2010e5c8900f9c32cab789c97637451558a7d353b8fb311e04fc0c097c44b0bf
BLAKE2b-256 checksum
How to use checksums
71f291cb3b20775150f3e497bb586bd2ec2fc1ce32ebd65a172ec9a69b628355
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.4.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