--- id: pyshex version: "0.9.0" license: CC0 1.0 Universal license_treatment: permissive maintenance: active --- # PyShEx — Python ShEx interpreter License: permissive · Maintenance: active · Downloads: 302.6K/mo ## What it is and what it does PyShEx is a Python implementation of the Shape Expressions Language 2.0 specification, allowing you to parse ShEx schemas (in both ShExC and ShExJ formats) and validate RDF graphs against them. It determines whether RDF nodes and their properties conform to the structural and type constraints defined in a ShEx schema, supporting features like SPARQL-based focus node selection, RDF Collections flattening, and detailed validation reporting. The package wraps the formal ShEx specification closely in Python code, translating semantic rules directly into executable logic. It includes a command-line tool (shexeval) for batch validation and integrates with rdflib for RDF parsing and SPARQL endpoints. The package depends on ShExJSG for AST representation, pyshexc for ShExC parsing, and several RDF utilities (rdflib-shim, sparqlwrapper, sparqlslurper) to handle diverse RDF sources and query patterns. Use it for: - Validate RDF data against organizational or domain-specific shape constraints before ingesting into a knowledge graph. - Test RDF export pipelines to ensure generated triples conform to expected structural schemas. - Query SPARQL endpoints and validate the results against ShEx schemas in a single workflow. - Batch-validate large RDF files or multiple datasets using the shexeval CLI with focus node selection by type or predicate. - Integrate shape validation into linked data publishing pipelines to catch schema violations early. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. PyShEx parses and validates RDF data against Shape Expressions (ShEx) schemas, implementing the ShEx 2.0 specification to check whether RDF graphs conform to defined structural constraints. Yes, with conditions. Install if you need to validate RDF against ShEx schemas and can tolerate that some unit tests are failing due to a long maintenance gap. The package is actively maintained now and supports current Python versions (3.10–3.14), but review the open issues and test manifest before relying on complex or edge-case validation logic. No known security vulnerabilities. ## Install pip install pyshex uv add pyshex poetry add pyshex ## Installing PyShEx Before you install: Low install friction with a pure-Python wheel. Maintenance is active but the package carries a caveat: the current release was issued to support Python 3.14 after a long development hiatus, and some unit tests remain failing due to outdated code or genuine bugs—consult issues before relying on edge cases. License in practice: Licensed under CC0 1.0 Universal (public domain dedication), placing no restrictions on use, modification, or distribution for any purpose. Quickstart: pip install PyShEx from pyshex.shex_evaluator import ShExEvaluator evaluator = ShExEvaluator(rdf='data.ttl', shex='schema.shex') result = evaluator.evaluate() Requires Python 3.10 or later. If using JSON-LD parsing, note that rdflib-jsonld is incompatible with the bleeding-edge rdflib version needed for single-quote escaping in RDF literals. Verify before relying: - Whether all 81 skipped tests in the official test suite (52 bnode identity, 18 ShEx 2.1 IMPORT, 3 shapemap, 2 relative IRI, 6 rdflib quote escaping) affect real-world use cases. - Current status of the rdflib single-quote escaping issue and whether a workaround is available without using bleeding-edge rdflib. - Which specific unit tests are failing and whether they impact the validation semantics or only edge cases. ## Package facts - License: CC0 1.0 Universal (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 302.6K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags ShEx validation RDF, shape expressions interpreter, RDF schema validation, ShEx parser Python, RDF graph validation, ShEx 2.0 implementation, semantic web validation, rdf-validation, semantic-web, schema-validation [View on SkillFed](https://skillfed.io/packages/pyshex) · [View on PyPI](https://pypi.org/project/pyshex/)