Source code

Download source archive ↓

src/rdflib/plugins/sparql/results/graph.py

1from __future__ import annotations
2
3from typing import IO, Optional
4
5from rdflib.graph import Graph
6from rdflib.query import Result, ResultParser
7
8
9class GraphResultParser(ResultParser):
10    # type error: Signature of "parse" incompatible with supertype "ResultParser"
11    def parse(self, source: IO, content_type: Optional[str]) -> Result:  # type: ignore[override]
12        res = Result("CONSTRUCT")  # hmm - or describe?type_)
13        res.graph = Graph()
14        res.graph.parse(source, format=content_type)
15
16        return res