Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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.0a4

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.0a4
File Size Uploaded Provenance Actions
pyshifty-0.6.0a4.tar.gz 689.0 kB With provenance Details for pyshifty-0.6.0a4.tar.gz

Built distributions (wheels)

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

Total release size: 37.7 MB

Release files / pyshifty-0.6.0a4.tar.gz

Download URL pyshifty-0.6.0a4.tar.gz
Size 689.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d6b8ff120cb9a232b921621f20bdd420330c433465c08933344cd84a57fa98e5
BLAKE2b-256 checksum
How to use checksums
995a0e1191bfa1f3a74697cfee1b94a279854116c712f7f4f00f4cbd1430005a
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.0a4-cp39-abi3-win_amd64.whl

Download URL pyshifty-0.6.0a4-cp39-abi3-win_amd64.whl
Size 6.5 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
73630ab387350988e19b12354ad96dc375c29093a5ada34ef3b36d9d277946a9
BLAKE2b-256 checksum
How to use checksums
a00829d7cdb0745bc29f1201200562938f804a68fd3d2cc64bf4591ff8406c06
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.0a4-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL pyshifty-0.6.0a4-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
9dc4369d971a58db22381a023cfda11539c220f642f757b57714205c2656b604
BLAKE2b-256 checksum
How to use checksums
f81065e0b3be9c5b435ce61a2108368d1f6d67b17c68c18ba8c93d1881d94a6b
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.0a4-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL pyshifty-0.6.0a4-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
cb61fe31a9c9085d1c4da3d927c0174073e14c8d8a43061669d12d8831fc7aa2
BLAKE2b-256 checksum
How to use checksums
ec3204fc334a640a3c93c58be5b942f25edd3551bb0a5139463048887ace16e6
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.0a4-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL pyshifty-0.6.0a4-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
6e314010007efa04efb824c03d04b359c2451996f95872a250091be547635d04
BLAKE2b-256 checksum
How to use checksums
71a39bb65f709e852bd531343d6d3066da6d1f1c52c8ee89f1a62acae9b6857d
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.0a4-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL pyshifty-0.6.0a4-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
d134733ff487235168c418c9851604865496233d1fe4c2fe7eb2d8a26d6b5399
BLAKE2b-256 checksum
How to use checksums
ec3ff5b6b3f0dc12926c54ce681a3dfbe025cbb9bfe6419ec873a5e0a148690d
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.0a4-cp39-abi3-macosx_11_0_arm64.whl

Download URL pyshifty-0.6.0a4-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
db9e396b0301c7fe23966759e68bda9140ad7637949f51fcc582d0baef2eb667
BLAKE2b-256 checksum
How to use checksums
fa8ec54b95d207dfd4666cbb18b7d1c8aeac9a016f04811d918ef2215468cbf3
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.0a4

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.0a4.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
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