Skip to content

Commit fad1b31

Browse files
committed
tidy up rdflib type hints
1 parent 5203afe commit fad1b31

File tree

11 files changed

+19
-207
lines changed

11 files changed

+19
-207
lines changed

cwltool/cwlviewer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def _set_output_edges(self) -> None:
157157
pydot.Edge(output_edge_row["step"], output_edge_row["output"])
158158
)
159159

160-
def _get_root_graph_uri(self) -> rdflib.URIRef:
160+
def _get_root_graph_uri(self) -> rdflib.term.Identifier:
161161
with open(_get_root_query_path) as f:
162162
get_root_query = f.read()
163163
root = cast(
@@ -173,7 +173,7 @@ def _get_root_graph_uri(self) -> rdflib.URIRef:
173173
"Cannot identify root workflow! Notice that only Workflows can be visualized"
174174
)
175175

176-
workflow = root[0]["workflow"] # type: rdflib.URIRef
176+
workflow = root[0]["workflow"]
177177
return workflow
178178

179179
@classmethod

mypy-stubs/rdflib/container.pyi

-33
This file was deleted.

mypy-stubs/rdflib/events.pyi

-8
This file was deleted.

mypy-stubs/rdflib/exceptions.pyi

-33
This file was deleted.

mypy-stubs/rdflib/paths.pyi

-5
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ class Path:
1515
__truediv__: Callable[[Path, Union["URIRef", "Path"]], "SequencePath"]
1616
__mul__: Callable[[Path, str], "MulPath"]
1717
def __hash__(self) -> int: ...
18-
def __eq__(self, other: Any) -> bool: ...
1918
def __lt__(self, other: Any) -> bool: ...
20-
def __le__(self, other: Any) -> bool: ...
21-
def __ne__(self, other: Any) -> bool: ...
22-
def __gt__(self, other: Any) -> bool: ...
23-
def __ge__(self, other: Any) -> bool: ...
2419

2520
class InvPath(Path): ...
2621
class SequencePath(Path): ...
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

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
from io import BufferedIOBase
2-
from typing import Any, Dict, Iterator, List, Optional, Tuple, overload
1+
from typing import IO, Any, Dict, Iterator, List, Mapping, Optional, Tuple, overload
32

43
from rdflib import URIRef, Variable
4+
from rdflib.term import Identifier
55
from typing_extensions import SupportsIndex
66

7-
class ResultRow: # Tuple[Variable, URIRef]):
7+
class ResultRow(Tuple["Identifier", ...]):
88
def __new__(
9-
cls, values: Dict[Variable, URIRef], labels: List[Variable]
9+
cls, values: Mapping[Variable, Identifier], labels: List[Variable]
1010
) -> ResultRow: ...
11-
def __getattr__(self, name: str) -> Any: ...
11+
def __getattr__(self, name: str) -> Identifier: ...
1212
@overload
13-
def __getitem__(self, name: str) -> URIRef: ...
13+
def __getitem__(self, name: str) -> Identifier: ...
1414
@overload
15-
def __getitem__(self, __x: SupportsIndex) -> Variable | URIRef: ...
15+
def __getitem__(self, __x: SupportsIndex) -> Identifier: ...
1616
@overload
17-
def __getitem__(self, __x: slice) -> Tuple[Variable | URIRef, ...]: ...
18-
def get(self, name: str, default: Any | None = ...) -> URIRef: ...
19-
def asdict(self) -> Dict[Variable, URIRef]: ...
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]: ...
2020

2121
class Result:
2222
type: Any
@@ -28,14 +28,14 @@ class Result:
2828
def __iter__(self) -> Iterator[bool | ResultRow]: ...
2929
@staticmethod
3030
def parse(
31-
source: str | None = ...,
31+
source: IO[Any] | None = ...,
3232
format: str | None = ...,
3333
content_type: str | None = ...,
3434
**kwargs: Any
3535
) -> Result: ...
3636
def serialize(
3737
self,
38-
destination: str | BufferedIOBase | None = ...,
38+
destination: str | IO[Any] | None = ...,
3939
encoding: str = ...,
4040
format: str = ...,
4141
**args: Any

mypy-stubs/rdflib/serializer.pyi

-11
This file was deleted.

mypy-stubs/rdflib/store.pyi

-53
This file was deleted.

mypy-stubs/rdflib/term.pyi

+4-10
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ class Identifier(Node, str):
77
def eq(self, other: Any) -> bool: ...
88
def neq(self, other: Any) -> bool: ...
99

10-
class URIRef(Identifier):
10+
class IdentifiedNode(Identifier): ...
11+
12+
class URIRef(IdentifiedNode):
1113
def toPython(self) -> str: ...
1214
def n3(self, namespace_manager: Any | None = ...) -> str: ...
1315
def defrag(self) -> "URIRef": ...
@@ -16,7 +18,7 @@ class URIRef(Identifier):
1618
class Genid(URIRef): ...
1719
class RDFLibGenid(Genid): ...
1820

19-
class BNode(Identifier):
21+
class BNode(IdentifiedNode):
2022
def toPython(self) -> str: ...
2123
def n3(self, namespace_manager: Any | None = ...) -> str: ...
2224
def skolemize(
@@ -36,14 +38,6 @@ class Literal(Identifier):
3638
def n3(self, namespace_manager: Any | None = ...) -> str: ...
3739
def toPython(self) -> str: ...
3840

39-
def bind(
40-
datatype: str | None,
41-
pythontype: type,
42-
constructor: Callable[..., Any] | None = ...,
43-
lexicalizer: Callable[..., Any] | None = ...,
44-
datatype_specific: bool = ...,
45-
) -> None: ...
46-
4741
class Variable(Identifier):
4842
def toPython(self) -> str: ...
4943
def n3(self, namespace_manager: Any | None = ...) -> str: ...

mypy-stubs/rdflib/util.pyi

-29
This file was deleted.

0 commit comments

Comments
 (0)