Skip to content

Commit 2a5a0fc

Browse files
committed
sync types with cwltool
1 parent fa1490f commit 2a5a0fc

File tree

14 files changed

+140
-210
lines changed

14 files changed

+140
-210
lines changed

mypy-stubs/rdflib/container.pyi

Lines changed: 0 additions & 33 deletions
This file was deleted.

mypy-stubs/rdflib/events.pyi

Lines changed: 0 additions & 8 deletions
This file was deleted.

mypy-stubs/rdflib/exceptions.pyi

Lines changed: 0 additions & 33 deletions
This file was deleted.

mypy-stubs/rdflib/graph.pyi

Lines changed: 77 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
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+
)
214

315
from rdflib import query
416
from rdflib.collection import Collection
17+
from rdflib.paths import Path
518
from rdflib.resource import Resource
619
from rdflib.term import BNode, Identifier, Node
720

@@ -37,6 +50,12 @@ class Graph(Node):
3750
Optional[Identifier],
3851
],
3952
) -> 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: ...
4059
def __add__(self, other: Any) -> Graph: ...
4160
def set(self, triple: Any) -> None: ...
4261
def subjects(
@@ -47,7 +66,7 @@ class Graph(Node):
4766
) -> Iterable[Node]: ...
4867
def objects(
4968
self, subject: Optional[Any] = ..., predicate: Optional[Any] = ...
50-
) -> Iterable[Node]: ...
69+
) -> Iterable[Identifier]: ...
5170
def subject_predicates(self, object: Optional[Any] = ...) -> None: ...
5271
def subject_objects(self, predicate: Optional[Any] = ...) -> None: ...
5372
def predicate_objects(self, subject: Optional[Any] = ...) -> None: ...
@@ -87,13 +106,61 @@ class Graph(Node):
87106
) -> Any: ...
88107
def namespaces(self) -> Iterator[Tuple[Any, Any]]: ...
89108
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
90123
def serialize(
91124
self,
92-
destination: Optional[Any] = ...,
125+
destination: None = ...,
93126
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,
97164
) -> Union[bytes, str, "Graph"]: ...
98165
def parse(
99166
self,
@@ -103,7 +170,7 @@ class Graph(Node):
103170
location: Optional[Any] = ...,
104171
file: Optional[Any] = ...,
105172
data: Optional[Any] = ...,
106-
**args: Any
173+
**args: Any,
107174
) -> "Graph": ...
108175
def load(
109176
self, source: Any, publicID: Optional[Any] = ..., format: str = ...
@@ -116,7 +183,7 @@ class Graph(Node):
116183
initNs: Optional[Any] = ...,
117184
initBindings: Optional[Any] = ...,
118185
use_store_provided: bool = ...,
119-
**kwargs: Any
186+
**kwargs: Any,
120187
) -> query.Result: ...
121188
def update(
122189
self,
@@ -125,7 +192,7 @@ class Graph(Node):
125192
initNs: Optional[Any] = ...,
126193
initBindings: Optional[Any] = ...,
127194
use_store_provided: bool = ...,
128-
**kwargs: Any
195+
**kwargs: Any,
129196
) -> Any: ...
130197
def n3(self) -> str: ...
131198
def isomorphic(self, other: Any) -> bool: ...
@@ -177,7 +244,7 @@ class ConjunctiveGraph(Graph):
177244
location: Optional[Any] = ...,
178245
file: Optional[Any] = ...,
179246
data: Optional[Any] = ...,
180-
**args: Any
247+
**args: Any,
181248
) -> Graph: ...
182249

183250
class Seq:

mypy-stubs/rdflib/namespace/__init__.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,15 @@ class Namespace(str):
3636
def title(self) -> URIRef: ...
3737
def term(self, name: Any) -> URIRef: ...
3838
def __getitem__(self, key: Any) -> URIRef: ...
39+
def __getattr__(self, name: str) -> URIRef: ...
3940

4041
class URIPattern(str):
4142
def format(self, *args: Any, **kwargs: Any) -> str: ...
4243

43-
class DefinedNamespaceMeta(type): ...
44+
class DefinedNamespaceMeta(type):
45+
def __getitem__(cls, name: Any, default: Any | None = ...) -> URIRef: ...
46+
def __getattr__(cls, name: Any) -> URIRef: ...
47+
def __contains__(cls, item: Any) -> bool: ...
4448

4549
class DefinedNamespace(metaclass=DefinedNamespaceMeta):
4650
def __init__(self) -> None: ...

mypy-stubs/rdflib/paths.pyi

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from collections.abc import Generator
2+
from typing import Any, Callable, Union
3+
4+
from rdflib.term import Node as Node
5+
from rdflib.term import URIRef as URIRef
6+
7+
ZeroOrMore: str
8+
OneOrMore: str
9+
ZeroOrOne: str
10+
11+
class Path:
12+
__or__: Callable[[Path, Union["URIRef", "Path"]], "AlternativePath"]
13+
__invert__: Callable[[Path], "InvPath"]
14+
__neg__: Callable[[Path], "NegatedPath"]
15+
__truediv__: Callable[[Path, Union["URIRef", "Path"]], "SequencePath"]
16+
__mul__: Callable[[Path, str], "MulPath"]
17+
def __hash__(self) -> int: ...
18+
def __lt__(self, other: Any) -> bool: ...
19+
20+
class InvPath(Path): ...
21+
class SequencePath(Path): ...
22+
class AlternativePath(Path): ...
23+
class MulPath(Path): ...
24+
class NegatedPath(Path): ...

mypy-stubs/rdflib/plugin.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from typing import Any, Type, TypeVar
22

3-
from rdflib.exceptions import Error
4-
53
def register(name: str, kind: Any, module_path: str, class_name: str) -> None: ...
64

75
PluginT = TypeVar("PluginT")
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
1-
# Stubs for rdflib.plugins.parsers.notation3 (Python 3.5)
2-
#
3-
# NOTE: This dynamically typed stub was automatically generated by stubgen.
4-
5-
from typing import Any
6-
7-
class BadSyntax(SyntaxError):
8-
lines = ... # type: Any
9-
def __init__(self, uri: Any, lines: Any, argstr: Any, i: Any, why: Any): ...
10-
@property
11-
def message(self) -> Any: ...
1+
class BadSyntax(SyntaxError): ...

mypy-stubs/rdflib/query.pyi

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
1-
from io import BufferedIOBase
2-
from typing import Any, Dict, Optional, Union
1+
from typing import IO, Any, Dict, Iterator, List, Mapping, Optional, Tuple, overload
2+
3+
from rdflib import URIRef, Variable
4+
from rdflib.term import Identifier
5+
from typing_extensions import SupportsIndex
6+
7+
class ResultRow(Tuple["Identifier", ...]):
8+
def __new__(
9+
cls, values: Mapping[Variable, Identifier], labels: List[Variable]
10+
) -> ResultRow: ...
11+
def __getattr__(self, name: str) -> Identifier: ...
12+
@overload
13+
def __getitem__(self, name: str) -> Identifier: ...
14+
@overload
15+
def __getitem__(self, __x: SupportsIndex) -> Identifier: ...
16+
@overload
17+
def __getitem__(self, __x: slice) -> Tuple[Identifier, ...]: ...
18+
def get(self, name: str, default: Any | None = ...) -> Identifier: ...
19+
def asdict(self) -> Dict[str, Identifier]: ...
320

421
class Result:
522
type: Any
@@ -8,16 +25,17 @@ class Result:
825
graph: Any
926
def __init__(self, type_: str) -> None: ...
1027
bindings: Any
28+
def __iter__(self) -> Iterator[bool | ResultRow]: ...
1129
@staticmethod
1230
def parse(
13-
source: Any | None = ...,
14-
format: Any | None = ...,
15-
content_type: Any | None = ...,
31+
source: IO[Any] | None = ...,
32+
format: str | None = ...,
33+
content_type: str | None = ...,
1634
**kwargs: Any
17-
) -> Any: ...
35+
) -> Result: ...
1836
def serialize(
1937
self,
20-
destination: Optional[Union[str, BufferedIOBase]] = ...,
38+
destination: str | IO[Any] | None = ...,
2139
encoding: str = ...,
2240
format: str = ...,
2341
**args: Any

mypy-stubs/rdflib/serializer.pyi

Lines changed: 0 additions & 11 deletions
This file was deleted.

mypy-stubs/rdflib/store.pyi

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)