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

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

Built distributions (wheels)

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

Total release size: 37.7 MB

Release files / pyshifty-0.6.0a3.tar.gz

Download URL pyshifty-0.6.0a3.tar.gz
Size 689.0 kB
Tags Source
SHA-256 checksum
How to use checksums
be80b27a943c5e68c8d152a721ae2e86211de4ea7662999a7d23b76c78f6d46b
BLAKE2b-256 checksum
How to use checksums
c245e1c6fb9f4286351051ae750ff4554a2b23ca61e120bd17a5f402cf511be1
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 10, 2026.

Transparency log

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

Download URL pyshifty-0.6.0a3-cp39-abi3-win_amd64.whl
Size 6.5 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
f3e8af0dac92da71150389acc921577e43447662c314e35523744703555c3169
BLAKE2b-256 checksum
How to use checksums
bed4666e2daaaa771d9e33acb3127178cd550f47dbc158b1102abc4782c6a32d
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 10, 2026.

Transparency log

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

Download URL pyshifty-0.6.0a3-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
c14aa54299bf4bbcd841498ea425af3b36652fc72834ae9a74f3b16cc97a793b
BLAKE2b-256 checksum
How to use checksums
f92f6b28ba238604c07e6a344c6407c04afb91bfeee95a8f3fc8c294518d14dd
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 10, 2026.

Transparency log

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

Download URL pyshifty-0.6.0a3-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
013df236c0efd8c5301528e1ba213cf14a5cb3c29a2a93d82f7149954841e993
BLAKE2b-256 checksum
How to use checksums
4716dd00b3e3bd203e89fee5b499b38796f644956dd8d2f547d01ff81b32ff33
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 10, 2026.

Transparency log

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

Download URL pyshifty-0.6.0a3-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
a75d6c8a71fdc28e46c376e567f72d2230a6d229c6e8425d022f5fd4d9ea208e
BLAKE2b-256 checksum
How to use checksums
1cf789a0002959caf0a4d68ccca2bda5bf28a9f1404410851476d4757a90be49
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 10, 2026.

Transparency log

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

Download URL pyshifty-0.6.0a3-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
79aefa125aa06e8f387c1e9956a85fb7817ba75ab69b04070d34324e19cec251
BLAKE2b-256 checksum
How to use checksums
32dda4fe892e1b486a9f84859428ada499f5a111ab09a78b09faa60e82e7f44a
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 10, 2026.

Transparency log

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

Download URL pyshifty-0.6.0a3-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
64275e991de3dd4729b4f200b28497c08a5ae735ea267207a9925c5e816b8cb0
BLAKE2b-256 checksum
How to use checksums
b6207ffed82105b33b165306317db0d95ba67972fadbaed0dfd872e14ac3f486
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 10, 2026.

Transparency log

Security for pyshifty 0.6.0a3

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.0a3.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 10, 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