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.
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:
labeledShapeExpr- The official JSG implemention specifies a strange pattern where the objects with atypeof"ShapeOr","ShapeAnd", ... are recognized as instances ofShapeOr,ShapeAnd, ... if they lack anidelement and aslabeledShapeOr,labeledShapeAnd, ... if theidelement exists. We simplify this construct, leavingidoptional. 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 thelabeledShapeExprbranch)- 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:
uv syncuv 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)
| File | Size | Uploaded | |
|---|---|---|---|
| shexjsg-0.9.0.tar.gz | 65.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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 logRelease 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