Skip to main content

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, in shifty.experimental.repair.

Start with the tutorials or look up these interfaces in the reference.

Write shapes in Python

shifty.experimental.shapeshift builds Shapeshift modules, shifty's text language for shapes, and writes them as .shm or SHACL. Shapeshift is experimental: the language and the module can change in any release:

from shifty.experimental import shapeshift as ss
from shifty.experimental.shapeshift import Class, Path, Shape

BRICK = ss.Namespace("brick", "https://brickschema.org/schema/Brick#")
m = ss.Module("vav", base="urn:example/vav/")
m.points = Path(BRICK.hasPoint)

@m.template
def with_point(cls: Class, n: int = 1):
    """At least `n` points of class `cls`."""
    return m.points.at_least(n, on_box=cls)

m.vav = Shape(
    BRICK.VAV,                                           # is a brick:VAV
    m.points.required(flow=BRICK.Discharge_Air_Flow_Sensor),
    m.damper | m.damper_command,                         # any of; defined below
    temp=with_point(BRICK.Zone_Air_Temperature_Sensor),  # a named line
    for_every=BRICK.VAV,
)
m.damper = BRICK.hasPart.at_least(1, BRICK.Damper)
m.damper_command = m.points.required(BRICK.Damper_Position_Command)

print(m)            # vav.shm, formatted as `shifty shape fmt` would
ttl = m.export()    # SHACL Turtle for shifty.validate
m.write_shacl("shapes/")   # or write it to shapes/vav.ttl

Assigning to a module defines a name (m.damper is shape damper), and reading a name not yet defined refers to it, so a module can read top-down. &, |, and ~ combine shapes as conjunction, any of, and none of; BRICK.AHU | BRICK.RTU is either class, and BRICK.Room & lines is a room whose lines hold. Keyword arguments name lines. In the repository, the Guideline 36 sequences and fault conditions in examples/shapeshift/g36/ are written this way, and generate.py writes their .shm files.

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.

Metadata

Release files for pyshifty 0.6.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 pyshifty 0.6.0
File Size Uploaded Provenance Actions
pyshifty-0.6.0.tar.gz 688.7 kB With provenance Details for pyshifty-0.6.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pyshifty 0.6.0
File Actions
pyshifty-0.6.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for pyshifty-0.6.0-cp39-abi3-win_amd64.whl
pyshifty-0.6.0-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details for pyshifty-0.6.0-cp39-abi3-musllinux_1_2_x86_64.whl
pyshifty-0.6.0-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details for pyshifty-0.6.0-cp39-abi3-musllinux_1_2_aarch64.whl
pyshifty-0.6.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for pyshifty-0.6.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
pyshifty-0.6.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for pyshifty-0.6.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
pyshifty-0.6.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for pyshifty-0.6.0-cp39-abi3-macosx_11_0_arm64.whl

Total release size: 37.7 MB

Release files / pyshifty-0.6.0.tar.gz

Download URL pyshifty-0.6.0.tar.gz
Size 688.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0d29cac4ec92c56394446c746acaf4330cef368329263782fc8252c5801b655a
BLAKE2b-256 checksum
How to use checksums
aef73ef062ab00d8fab49255bb35070202bac4491028bbc0c94d13ba90ba8054
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 11, 2026.

Transparency log

Release files / pyshifty-0.6.0-cp39-abi3-win_amd64.whl

Download URL pyshifty-0.6.0-cp39-abi3-win_amd64.whl
Size 6.5 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
df4d7c464b0b2610c908445871cef9b8f208a741642291c36725bef4de9db876
BLAKE2b-256 checksum
How to use checksums
a120d19e56ac8a51f787a716650b889b335338c2c62f5a446ffc36779c5fef0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 11, 2026.

Transparency log

Release files / pyshifty-0.6.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL pyshifty-0.6.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 6.4 MB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
ecacbbe6d6631f91a744fdb4a0690c237961e61b6dd0ed6b424860f57328685c
BLAKE2b-256 checksum
How to use checksums
5f34c8fefaff97da60c06eee5e514a533ff247d803b50b6e8ead8c3b92024287
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 11, 2026.

Transparency log

Release files / pyshifty-0.6.0-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL pyshifty-0.6.0-cp39-abi3-musllinux_1_2_aarch64.whl
Size 6.0 MB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
51b54a0a6802413e456263687bdb06327b67b2cd66622e834c1e1eae530b28a4
BLAKE2b-256 checksum
How to use checksums
506d0843faa0ae44e45e2be391d5b74e0430e7e0c9a3ec2a6d5be38896cbd8b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 11, 2026.

Transparency log

Release files / pyshifty-0.6.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL pyshifty-0.6.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 6.4 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
cf7b1f7d995d742c4ef5bf793e0ae57be356e2554a01b3003404c5f5ed621539
BLAKE2b-256 checksum
How to use checksums
5f16bf16a77c61e2cd424efb926aa6238a27a2f5c7329d6f22d997dc7b972614
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 11, 2026.

Transparency log

Release files / pyshifty-0.6.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL pyshifty-0.6.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 6.0 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
0eadf237a084f5c8f71d2c768e62559abcbd31c77013d0faf2a024fd707e91fd
BLAKE2b-256 checksum
How to use checksums
c2c9c038f57ebda2ab8293777666e37dd1fe8f50e6b0a417724b7beaaa319f8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 11, 2026.

Transparency log

Release files / pyshifty-0.6.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL pyshifty-0.6.0-cp39-abi3-macosx_11_0_arm64.whl
Size 5.8 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
dc849ab43c4e8e3874692676bb9e2598a6277e259b2a00990f19052622066b63
BLAKE2b-256 checksum
How to use checksums
f9d23b9f1387bbe7c78e5f011ef15d049f3478495d8fbc0261d4fc321a6cbe2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 11, 2026.

Transparency log

Security for pyshifty 0.6.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.

Full provenance

All 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for pyshifty-0.6.0.tar.gz

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 Nov 11, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.6.0 This release

7 release files Full provenance

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