query_sparql
Execute SPARQL queries to explore Python code structure: retrieve functions, classes, callers, dependencies, and inheritance relationships across the repository.
Instructions
Prefix: code: http://example.org/code-ontology# Node IRIs: urn:code:<repo/relative/path.py> (module), urn:code:<path.py>::<Qualified.Name> (class/function).
Classes: code:Module, code:Class, code:Function Datatype properties: code:name, code:startLine, code:endLine, code:signature, code:returnType, code:description, code:contentHash Object properties: code:defines (parent->child), code:belongsTo (child->parent, inverse of defines), code:reads, code:writes, code:raises, code:decoratedBy, code:imports, code:calls, code:inherits (imports/calls/inherits objects may be a string Literal if unresolved, or a NamedNode if Pyright resolved the target — both may be present)
Named graphs: urn:code:graph:<path.py> holds one file's direct/structural triples; urn:code:graph:inferred holds the fully materialized transitive closure (R+, includes direct edges) of calls/imports/inherits across the whole repo.
Every query runs with use_default_graph_as_union=True, so a plain WHERE clause with no GRAPH block already searches across every named graph — add an explicit GRAPH urn:code:graph:inferred { ... } block only when you specifically want the transitive/materialized edges rather than a single file's direct ones.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |