Skip to content

Commit 3aa5aa1

Browse files
committed
improve support for rdflib > 5
1 parent 54458a4 commit 3aa5aa1

40 files changed

+3479
-298
lines changed

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
ruamel.yaml>= 0.12.4, != 0.16.6, < 0.18
2+
rdflib>= 4.2.2, < 6.0.0;python_version<='3.6'
23
rdflib>= 4.2.2, < 7.0.0
3-
rdflib-jsonld>=0.4.0, <0.7.0
4+
rdflib-jsonld>=0.4.0, <= 0.6.1;python_version<='3.6'
45
mistune>=0.8.1,<0.9
56
CacheControl==0.12.6
67
lockfile==0.12.2

schema_salad/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from urllib.parse import urlparse
99

1010
import pkg_resources # part of setuptools
11+
from rdflib import __version__ as rdflib_version
1112
from rdflib.parser import Parser
1213
from rdflib.plugin import register
1314
from ruamel.yaml.comments import CommentedMap, CommentedSeq
@@ -19,7 +20,8 @@
1920
from .ref_resolver import Loader, file_uri
2021
from .utils import json_dump, stdout
2122

22-
register("json-ld", Parser, "rdflib_jsonld.parser", "JsonLDParser")
23+
if int(rdflib_version.split(".")[0]) < 6:
24+
register("json-ld", Parser, "rdflib_jsonld.parser", "JsonLDParser")
2325
_logger = logging.getLogger("salad")
2426

2527

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@
7676
"ruamel.yaml >= 0.12.4, != 0.16.6, < 0.18",
7777
# once the minimum version for ruamel.yaml >= 0.15.99
7878
# then please update the mypy targets in the Makefile
79+
"rdflib >= 4.2.2, < 6.0.0;python_version<='3.6'",
7980
"rdflib >= 4.2.2, < 7.0.0",
80-
"rdflib-jsonld >= 0.3.0, < 0.7.0",
81+
"rdflib-jsonld >= 0.3.0, <= 0.6.1;python_version<='3.6'",
8182
"mistune >= 0.8.1, < 0.9",
8283
"CacheControl >= 0.11.7, < 0.13",
8384
"lockfile >= 0.9",

typeshed/rdflib/__init__.pyi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
from rdflib.container import *
12
from rdflib import util as util
23
from rdflib.graph import ConjunctiveGraph as ConjunctiveGraph, Dataset as Dataset, Graph as Graph
3-
from rdflib.namespace import CSVW as CSVW, DC as DC, DCAT as DCAT, DCTERMS as DCTERMS, DOAP as DOAP, FOAF as FOAF, Namespace as Namespace, ODRL2 as ODRL2, ORG as ORG, OWL as OWL, PROF as PROF, PROV as PROV, RDF as RDF, RDFS as RDFS, SDO as SDO, SH as SH, SKOS as SKOS, SOSA as SOSA, SSN as SSN, TIME as TIME, VOID as VOID, XMLNS as XMLNS, XSD as XSD
4+
from rdflib.namespace import CSVW as CSVW, DC as DC, DCAT as DCAT, DCTERMS as DCTERMS, DOAP as DOAP, FOAF as FOAF, Namespace as Namespace, ODRL2 as ODRL2, ORG as ORG, OWL as OWL, PROF as PROF, PROV as PROV, QB as QB, RDF as RDF, RDFS as RDFS, SDO as SDO, SH as SH, SKOS as SKOS, SOSA as SOSA, SSN as SSN, TIME as TIME, VOID as VOID, XMLNS as XMLNS, XSD as XSD
45
from rdflib.term import BNode as BNode, Literal as Literal, URIRef as URIRef, Variable as Variable
6+
7+
__version__: str

typeshed/rdflib/container.pyi

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from typing import Any
2+
3+
class Container:
4+
graph: Any
5+
uri: Any
6+
def __init__(self, graph, uri, seq=..., rtype: str = ...) -> None: ...
7+
def n3(self): ...
8+
def __len__(self): ...
9+
def type_of_conatiner(self): ...
10+
def index(self, item): ...
11+
def __getitem__(self, key): ...
12+
def __setitem__(self, key, value) -> None: ...
13+
def __delitem__(self, key) -> None: ...
14+
def items(self): ...
15+
def end(self): ...
16+
def append(self, item): ...
17+
def append_multiple(self, other): ...
18+
def clear(self): ...
19+
20+
class Bag(Container):
21+
def __init__(self, graph, uri, seq=...) -> None: ...
22+
23+
class Alt(Container):
24+
def __init__(self, graph, uri, seq=...) -> None: ...
25+
def anyone(self): ...
26+
27+
class Seq(Container):
28+
def __init__(self, graph, uri, seq=...) -> None: ...
29+
def add_at_position(self, pos, item): ...
30+
31+
class NoElementException(Exception):
32+
message: Any
33+
def __init__(self, message: str = ...) -> None: ...

typeshed/rdflib/events.pyi

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
# Stubs for rdflib.events (Python 2)
2-
#
3-
# NOTE: This dynamically typed stub was automatically generated by stubgen.
4-
51
class Event:
6-
def __init__(self, **kw): ...
2+
def __init__(self, **kw) -> None: ...
73

84
class Dispatcher:
95
def set_map(self, amap): ...
106
def get_map(self): ...
117
def subscribe(self, event_type, handler): ...
12-
def dispatch(self, event): ...
8+
def dispatch(self, event) -> None: ...

typeshed/rdflib/exceptions.pyi

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,33 @@
1-
# Stubs for rdflib.exceptions (Python 2)
2-
#
3-
# NOTE: This dynamically typed stub was automatically generated by stubgen.
4-
51
from typing import Any
62

73
class Error(Exception):
8-
msg = ... # type: Any
9-
def __init__(self, msg=None): ...
4+
msg: Any
5+
def __init__(self, msg: Any | None = ...) -> None: ...
106

117
class TypeCheckError(Error):
12-
type = ... # type: Any
13-
node = ... # type: Any
14-
def __init__(self, node): ...
8+
type: Any
9+
node: Any
10+
def __init__(self, node) -> None: ...
1511

1612
class SubjectTypeError(TypeCheckError):
17-
msg = ... # type: Any
18-
def __init__(self, node): ...
13+
msg: Any
14+
def __init__(self, node) -> None: ...
1915

2016
class PredicateTypeError(TypeCheckError):
21-
msg = ... # type: Any
22-
def __init__(self, node): ...
17+
msg: Any
18+
def __init__(self, node) -> None: ...
2319

2420
class ObjectTypeError(TypeCheckError):
25-
msg = ... # type: Any
26-
def __init__(self, node): ...
21+
msg: Any
22+
def __init__(self, node) -> None: ...
2723

2824
class ContextTypeError(TypeCheckError):
29-
msg = ... # type: Any
30-
def __init__(self, node): ...
25+
msg: Any
26+
def __init__(self, node) -> None: ...
3127

3228
class ParserError(Error):
33-
msg = ... # type: Any
34-
def __init__(self, msg): ...
29+
msg: Any
30+
def __init__(self, msg) -> None: ...
3531

3632
class UniquenessError(Error):
37-
def __init__(self, values): ...
33+
def __init__(self, values) -> None: ...

typeshed/rdflib/graph.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from rdflib.term import BNode, Node
1+
from rdflib.term import BNode, Node, Identifier
22
from typing import overload, Any, Iterator, Optional, Tuple, Union
33

44
class Graph(Node):
@@ -19,7 +19,7 @@ class Graph(Node):
1919
def add(self, triple: Any) -> None: ...
2020
def addN(self, quads: Any) -> None: ...
2121
def remove(self, triple: Any) -> None: ...
22-
def triples(self, triple: Tuple[Optional[Union[str, BNode]], Optional[Union[str, BNode]], Optional[BNode]]) -> Iterator[Tuple[BNode, BNode, BNode]]: ...
22+
def triples(self, triple: Tuple[Optional[Union[str, Identifier]], Optional[Union[str, Identifier]], Optional[Identifier]]) -> Iterator[Tuple[Identifier, Identifier, Identifier]]: ...
2323
def __getitem__(self, item: Any): ...
2424
def __len__(self): ...
2525
def __iter__(self) -> Any: ...
@@ -85,7 +85,7 @@ class ConjunctiveGraph(Graph):
8585
def add(self, triple_or_quad: Any) -> None: ...
8686
def addN(self, quads: Any) -> None: ...
8787
def remove(self, triple_or_quad: Any) -> None: ...
88-
#def triples(self, triple_or_quad: Tuple[Optional[Union[str, BNode]], Optional[Union[str, BNode]], Optional[BNode]], context: Tuple[Optional[Union[str, BNode]], Optional[Union[str, BNode]], Optional[BNode]]) -> Iterator[Tuple[BNode, BNode, BNode]]: ...
88+
#def triples(self, triple_or_quad: Tuple[Optional[Union[str, BNode]], Optional[Union[str, BNode]], Optional[BNode]], context: Tuple[Optional[Union[str, BNode]], Optional[Union[str, BNode]], Optional[BNode]]) -> Iterator[Tuple[Identifier, Identifier, Identifier]]: ...
8989
def quads(self, triple_or_quad: Optional[Any] = ...) -> None: ...
9090
def triples_choices(self, triple: Any, context: Optional[Any] = ...) -> None: ...
9191
def __len__(self): ...
@@ -138,7 +138,7 @@ class ReadOnlyGraphAggregate(ConjunctiveGraph):
138138
def add(self, triple: Any) -> None: ...
139139
def addN(self, quads: Any) -> None: ...
140140
def remove(self, triple: Any) -> None: ...
141-
def triples(self, triple: Tuple[Optional[Union[str, BNode]], Optional[Union[str, BNode]], Optional[BNode]]) -> Iterator[Tuple[BNode, BNode, BNode]]: ...
141+
def triples(self, triple: Tuple[Optional[Union[str, Identifier]], Optional[Union[str, Identifier]], Optional[Identifier]]) -> Iterator[Tuple[Identifier, Identifier, Identifier]]: ...
142142
def __contains__(self, triple_or_quad: Any): ...
143143
def __len__(self): ...
144144
def __hash__(self) -> Any: ...

typeshed/rdflib/namespace.pyi

Lines changed: 0 additions & 112 deletions
This file was deleted.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
from rdflib.namespace import DefinedNamespace as DefinedNamespace, Namespace as Namespace
2+
from rdflib.term import URIRef as URIRef
3+
4+
class CSVW(DefinedNamespace):
5+
aboutUrl: URIRef
6+
base: URIRef
7+
column: URIRef
8+
columnReference: URIRef
9+
commentPrefix: URIRef
10+
datatype: URIRef
11+
decimalChar: URIRef
12+
default: URIRef
13+
delimiter: URIRef
14+
describes: URIRef
15+
dialect: URIRef
16+
doubleQuote: URIRef
17+
encoding: URIRef
18+
foreignKey: URIRef
19+
format: URIRef
20+
groupChar: URIRef
21+
header: URIRef
22+
headerRowCount: URIRef
23+
lang: URIRef
24+
length: URIRef
25+
lineTerminators: URIRef
26+
maxExclusive: URIRef
27+
maxInclusive: URIRef
28+
maxLength: URIRef
29+
minExclusive: URIRef
30+
minInclusive: URIRef
31+
minLength: URIRef
32+
name: URIRef
33+
note: URIRef
34+
null: URIRef
35+
ordered: URIRef
36+
pattern: URIRef
37+
primaryKey: URIRef
38+
propertyUrl: URIRef
39+
quoteChar: URIRef
40+
reference: URIRef
41+
referencedRow: URIRef
42+
required: URIRef
43+
resource: URIRef
44+
row: URIRef
45+
rowTitle: URIRef
46+
rownum: URIRef
47+
schemaReference: URIRef
48+
scriptFormat: URIRef
49+
separator: URIRef
50+
skipBlankRows: URIRef
51+
skipColumns: URIRef
52+
skipInitialSpace: URIRef
53+
skipRows: URIRef
54+
source: URIRef
55+
suppressOutput: URIRef
56+
table: URIRef
57+
tableDirection: URIRef
58+
tableSchema: URIRef
59+
targetFormat: URIRef
60+
textDirection: URIRef
61+
title: URIRef
62+
transformations: URIRef
63+
trim: URIRef
64+
url: URIRef
65+
valueUrl: URIRef
66+
virtual: URIRef
67+
Cell: URIRef
68+
Column: URIRef
69+
Datatype: URIRef
70+
Dialect: URIRef
71+
Direction: URIRef
72+
ForeignKey: URIRef
73+
NumericFormat: URIRef
74+
Row: URIRef
75+
Schema: URIRef
76+
Table: URIRef
77+
TableGroup: URIRef
78+
TableReference: URIRef
79+
Transformation: URIRef
80+
JSON: URIRef
81+
uriTemplate: URIRef
82+
auto: URIRef
83+
inherit: URIRef
84+
ltr: URIRef
85+
rtl: URIRef
86+
csvEncodedTabularData: URIRef
87+
tabularMetadata: URIRef

0 commit comments

Comments
 (0)