Skip to main content

This repository was originally developed by Harold Solbrig and was kindly contributed to the LinkML organization because of his retirement. All credit for the original development of this repository goes to him.

ShExJSG -

Python representation of the ShEx AST(ish) specification.

Pyversions PyPi Build Publish

Use:

from ShExJSG import Schema, ShExJ
from PyShExC import ShExC
from pyjsg.jsglib.loader import is_valid

schema = Schema()

schema.start = ShExJ.Shape()

print(is_valid(schema))
print(schema._as_json_dumps())
print(str(ShExC(schema)))
True
{
   "@context": "http://www.w3.org/ns/shex.jsonld",
   "start": {
      "type": "Shape"
   },
   "type": "Schema"
}
 start=  { }

ShExJ.jsg

This file is derived from the ShEx JSG specification. The differences are as follows:

  1. labeledShapeExpr - The official JSG implemention specifies a strange pattern where the objects with a type of "ShapeOr", "ShapeAnd", ... are recognized as instances of ShapeOr, ShapeAnd, ... if they lack an id element and as labeledShapeOr, labeledShapeAnd, ... if the id element exists. We simplify this construct, leaving id optional. This potentially allows the parser to accept some highly unlikely invalid constructs, but these can be checked in a post-parse step if you feel deeply about it. (Note also that the ShEx semantics document does not include the labeledShapeExpr branch)
  2. This uses the revised jsg syntax.

ShExJ.py

Output of the PyJSG generate_parser for ShExJ.jsg. Python 3 representation of the ShEx AST

Installation

This package currently requires python 3.6 or later. It could be updated to support earlier python 3 versions if there is sufficient demand.

pip install ShExJSG

Updating the parser

cd ShExJSG
generate_parser ShExJ.jsg

Then run all tests:

uv run pytest

Note for developers

The original way this library was developed created a circular dependency for the test environment, causing uv to fail to resolve. The reason is that ShExJSG is a runtime dependency for pyshexc, while pyshexc is a dev dependency for ShExJSG. The only way around this is to run the development install the following way after cloning:

  1. uv sync
  2. uv pip install "pyshexc>=0.10.3"

Release files for ShExJSG 0.9.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 ShExJSG 0.9.0
File Size Uploaded
shexjsg-0.9.0.tar.gz 65.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ShExJSG 0.9.0
File Interpreter ABI Platform
shexjsg-0.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 80.5 kB

Release files / shexjsg-0.9.0.tar.gz

Download URL shexjsg-0.9.0.tar.gz
Size 65.2 kB
Tags Source
SHA-256 checksum
How to use checksums
750016fabdb5487b27e2e714145f3602cd3ac4eb0dd9b7d7751d0cde62c0d1d8
BLAKE2b-256 checksum
How to use checksums
d4d66e948660a888a37a5100e7bf7109e89b249ed526df430b674da12950de17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 May 4, 2026.

Transparency log

Release files / shexjsg-0.9.0-py3-none-any.whl

Download URL shexjsg-0.9.0-py3-none-any.whl
Size 15.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
abf18db2d9895bc46740f68ae699b2ccfe08c783f6e0c038e6077293ad01c0a5
BLAKE2b-256 checksum
How to use checksums
8672b03ca1560615933f079ba7d291d3532ed95c2a3205911fe71d192654acaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 May 4, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.8

1 release file

0.6.7

1 release file

0.6.5

1 release file

0.6.3

1 release file

0.6.2

1 release file

0.5.6

1 release file

0.5.5

1 release file

0.5.4

1 release file

0.5.3

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

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