pyshifty
pyshifty is the Python package for Shifty,
a SHACL validation and SHACL-AF inference engine for RDF graphs. Install the
distribution as pyshifty and import it as shifty.
Documentation · Python API · Feature support
Install
pip install pyshifty
The core validation, inference, and evidence paths do not require rdflib.
Install the extra when using validate() or an API that returns an
rdflib.Graph:
pip install "pyshifty[rdflib]"
Python 3.9 or newer is supported. Published wheels include the Rust engine.
Validate
import shifty
shapes = """
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix ex: <http://example.org/> .
ex:PersonShape a sh:NodeShape ;
sh:targetClass ex:Person ;
sh:property [ sh:path ex:name ; sh:minCount 1 ] .
"""
data = """
@prefix ex: <http://example.org/> .
ex:alice a ex:Person ; ex:name "Alice" .
ex:bob a ex:Person .
"""
result = shifty.validate_algebra(data, shapes)
assert not result.conforms
for violation in result.violations:
for reason in violation.reasons:
print(violation.focus_node, reason.constraint_kind, reason.path)
# With the rdflib extra installed:
conforms, report_graph, results_text = shifty.validate(data, shapes)
The first call returns typed violations and reasons. The second returns a
W3C sh:ValidationReport graph and text. Both take data first and shapes
second. See validation interfaces
for the reporting tradeoffs and the API reference
for accepted arguments.
Inputs may be Turtle text or bytes, local paths, HTTP(S) URLs, pathlib.Path,
or rdflib.Graph. Lists and tuples merge sources before evaluation. Omit the
shapes argument when shapes and data are in one graph.
Infer
import shifty
rules = """
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix ex: <http://example.org/> .
ex:RectangleShape a sh:NodeShape ;
sh:targetClass ex:Rectangle ;
sh:rule [
a sh:TripleRule ;
sh:subject sh:this ;
sh:predicate ex:area ;
sh:object [ sh:path ex:width ] ;
] .
"""
rectangles = """
@prefix ex: <http://example.org/> .
ex:r1 a ex:Rectangle ; ex:width 3 .
"""
inferred = shifty.infer(rectangles, rules)
assert inferred.inferred_count == 1
print(inferred.inferred_ntriples)
inferred.graph_ntriples contains the input and derived triples.
inferred.graph() returns that graph as rdflib.Graph when the extra is
installed. See the inference guide
for in-place updates and inference during validation.
Reuse shapes and inspect results
PreparedValidator(shapes) compiles a schema once for use with many data
graphs. EvidenceSession records passing and failing focus nodes and their
derivations. shape_map() extracts typed property bindings, including partial
bindings for a focus node that fails another constraint. Symbolic repair is
experimental. Start with the tutorials
or look up these interfaces in the reference.
Develop from a checkout
From python/, use the locked uv environment:
uv sync --dev --frozen --reinstall-package pyshifty
uv run ruff check .
uv run ruff format --check .
uv run ty check shifty
uv run pytest -q
Reinstall after changing Rust sources so the editable extension is rebuilt. The contribution guide has the other frontend build instructions.
License
BSD-3-Clause.
Release files for pyshifty 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyshifty-0.5.0.tar.gz | 536.1 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pyshifty-0.5.0-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details |
| pyshifty-0.5.0-cp39-abi3-musllinux_1_2_x86_64.whl | CPython 3.9 | abi3 | Linux musl 1.2+ x86-64 | Details |
| pyshifty-0.5.0-cp39-abi3-musllinux_1_2_aarch64.whl | CPython 3.9 | abi3 | Linux musl 1.2+ ARM64 | Details |
| pyshifty-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| pyshifty-0.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| pyshifty-0.5.0-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details |
Total release size: 25.3 MB
Release files / pyshifty-0.5.0.tar.gz
| Download URL | pyshifty-0.5.0.tar.gz |
|---|---|
| Size | 536.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
32e80619e2eea47be05b504b05cd86701d49fc420cf1b4125033f3277eed3a7a
|
|
BLAKE2b-256 checksum How to use checksums |
ef50cbae094b2ca2c2c1c5eaaa3bf9db49cf9603ba9972cce74d80e692441aa2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.
Transparency logRelease files / pyshifty-0.5.0-cp39-abi3-win_amd64.whl
| Download URL | pyshifty-0.5.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 4.3 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
bfdf581169c1c895737db57b14b23e9f733130c1d8b86656b11fcab76c5776f2
|
|
BLAKE2b-256 checksum How to use checksums |
fd2f26d6dfc48cb88cdddbf280c0273c6910a07c8e9ec238a6591dba6f77e0dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.
Transparency logRelease files / pyshifty-0.5.0-cp39-abi3-musllinux_1_2_x86_64.whl
| Download URL | pyshifty-0.5.0-cp39-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 4.3 MB |
| Tags | CPython 3.9 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
11f1bbd39ecd167e7a6574d582cda7c233934d5301d74ffe338072d14d34b1d7
|
|
BLAKE2b-256 checksum How to use checksums |
7b621cd2d9bd01d3895d088b13d7f0d597da828fa88060859fc9e82a79fc2c6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.
Transparency logRelease files / pyshifty-0.5.0-cp39-abi3-musllinux_1_2_aarch64.whl
| Download URL | pyshifty-0.5.0-cp39-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 4.0 MB |
| Tags | CPython 3.9 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
868a8daf705f4aef5b6b04ec223c7ebdbd9706180deb453b1d6d577c2fe187f5
|
|
BLAKE2b-256 checksum How to use checksums |
fe713dd7cea807dfbb476407141a937593e90fdb98f0d371b35ac8d359ca4da6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.
Transparency logRelease files / pyshifty-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyshifty-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 4.3 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
370d066c1a41a11ab8b3434f07c4fad6e8e41261be33f221b5435beeed044389
|
|
BLAKE2b-256 checksum How to use checksums |
1ab23b46cc07dc418f74321c85d6e0620666ad7d4226026dad3c4f7fb67e6f05
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.
Transparency logRelease files / pyshifty-0.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | pyshifty-0.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 4.0 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
f199bd655ed6111ef8085f9aed254243cdc8774810eb953c4eb8f3d127307ff5
|
|
BLAKE2b-256 checksum How to use checksums |
9121f3579bf764953723e49f4865b1af8f58477f7380e3bb6c8cc66d636f8f9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.
Transparency logRelease files / pyshifty-0.5.0-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | pyshifty-0.5.0-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.9 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
db70901725aed5663bd45299c159d7619a023cfe3cf22e9504cc72f6554ccea7
|
|
BLAKE2b-256 checksum How to use checksums |
77c2efab9dc78a929ad5f4c0a5195c4a24f78758a2233a145e1d2885608b78a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.
Transparency log