1
- from typing import Any , Iterable , Iterator , List , Optional , Set , Tuple , Union , overload
1
+ import pathlib
2
+ from typing import (
3
+ IO ,
4
+ Any ,
5
+ Iterable ,
6
+ Iterator ,
7
+ List ,
8
+ Optional ,
9
+ Set ,
10
+ Tuple ,
11
+ Union ,
12
+ overload ,
13
+ )
2
14
3
15
from rdflib import query
4
16
from rdflib .collection import Collection
17
+ from rdflib .paths import Path
5
18
from rdflib .resource import Resource
6
19
from rdflib .term import BNode , Identifier , Node
7
20
@@ -37,6 +50,12 @@ class Graph(Node):
37
50
Optional [Identifier ],
38
51
],
39
52
) -> Iterator [Tuple [Identifier , Identifier , Identifier ]]: ...
53
+ def __getitem__ (
54
+ self , item : slice | Path | Node
55
+ ) -> Iterator [
56
+ Tuple [Identifier , Identifier , Identifier ] | Tuple [Identifier , identifier ] | Node
57
+ ]: ...
58
+ def __contains__ (self , triple : Any ) -> bool : ...
40
59
def __add__ (self , other : Any ) -> Graph : ...
41
60
def set (self , triple : Any ) -> None : ...
42
61
def subjects (
@@ -47,7 +66,7 @@ class Graph(Node):
47
66
) -> Iterable [Node ]: ...
48
67
def objects (
49
68
self , subject : Optional [Any ] = ..., predicate : Optional [Any ] = ...
50
- ) -> Iterable [Node ]: ...
69
+ ) -> Iterable [Identifier ]: ...
51
70
def subject_predicates (self , object : Optional [Any ] = ...) -> None : ...
52
71
def subject_objects (self , predicate : Optional [Any ] = ...) -> None : ...
53
72
def predicate_objects (self , subject : Optional [Any ] = ...) -> None : ...
@@ -87,13 +106,61 @@ class Graph(Node):
87
106
) -> Any : ...
88
107
def namespaces (self ) -> Iterator [Tuple [Any , Any ]]: ...
89
108
def absolutize (self , uri : Any , defrag : int = ...) -> Any : ...
109
+
110
+ # no destination and non-None positional encoding
111
+ @overload
112
+ def serialize (
113
+ self ,
114
+ destination : None ,
115
+ format : str ,
116
+ base : Optional [str ],
117
+ encoding : str ,
118
+ ** args : Any ,
119
+ ) -> bytes : ...
120
+
121
+ # no destination and non-None keyword encoding
122
+ @overload
90
123
def serialize (
91
124
self ,
92
- destination : Optional [ Any ] = ...,
125
+ destination : None = ...,
93
126
format : str = ...,
94
- base : Optional [Any ] = ...,
95
- encoding : Optional [Any ] = ...,
96
- ** args : Any
127
+ base : Optional [str ] = ...,
128
+ * ,
129
+ encoding : str ,
130
+ ** args : Any ,
131
+ ) -> bytes : ...
132
+
133
+ # no destination and None encoding
134
+ @overload
135
+ def serialize (
136
+ self ,
137
+ destination : None = ...,
138
+ format : str = ...,
139
+ base : Optional [str ] = ...,
140
+ encoding : None = ...,
141
+ ** args : Any ,
142
+ ) -> str : ...
143
+
144
+ # non-None destination
145
+ @overload
146
+ def serialize (
147
+ self ,
148
+ destination : Union [str , pathlib .PurePath , IO [bytes ]],
149
+ format : str = ...,
150
+ base : Optional [str ] = ...,
151
+ encoding : Optional [str ] = ...,
152
+ ** args : Any ,
153
+ ) -> "Graph" : ...
154
+
155
+ # fallback
156
+ @overload
157
+ def serialize (
158
+ self ,
159
+ destination : Optional [Union [str , pathlib .PurePath , IO [bytes ]]] = ...,
160
+ format : str = ...,
161
+ base : Optional [str ] = ...,
162
+ encoding : Optional [str ] = ...,
163
+ ** args : Any ,
97
164
) -> Union [bytes , str , "Graph" ]: ...
98
165
def parse (
99
166
self ,
@@ -103,7 +170,7 @@ class Graph(Node):
103
170
location : Optional [Any ] = ...,
104
171
file : Optional [Any ] = ...,
105
172
data : Optional [Any ] = ...,
106
- ** args : Any
173
+ ** args : Any ,
107
174
) -> "Graph" : ...
108
175
def load (
109
176
self , source : Any , publicID : Optional [Any ] = ..., format : str = ...
@@ -116,7 +183,7 @@ class Graph(Node):
116
183
initNs : Optional [Any ] = ...,
117
184
initBindings : Optional [Any ] = ...,
118
185
use_store_provided : bool = ...,
119
- ** kwargs : Any
186
+ ** kwargs : Any ,
120
187
) -> query .Result : ...
121
188
def update (
122
189
self ,
@@ -125,7 +192,7 @@ class Graph(Node):
125
192
initNs : Optional [Any ] = ...,
126
193
initBindings : Optional [Any ] = ...,
127
194
use_store_provided : bool = ...,
128
- ** kwargs : Any
195
+ ** kwargs : Any ,
129
196
) -> Any : ...
130
197
def n3 (self ) -> str : ...
131
198
def isomorphic (self , other : Any ) -> bool : ...
@@ -177,7 +244,7 @@ class ConjunctiveGraph(Graph):
177
244
location : Optional [Any ] = ...,
178
245
file : Optional [Any ] = ...,
179
246
data : Optional [Any ] = ...,
180
- ** args : Any
247
+ ** args : Any ,
181
248
) -> Graph : ...
182
249
183
250
class Seq :
0 commit comments