Skip to content

Commit

Permalink
tidy up rdflib type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed Aug 3, 2022
1 parent 5203afe commit cde1186
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 207 deletions.
4 changes: 2 additions & 2 deletions cwltool/cwlviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def _set_output_edges(self) -> None:
pydot.Edge(output_edge_row["step"], output_edge_row["output"])
)

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

workflow = root[0]["workflow"] # type: rdflib.URIRef
workflow = root[0]["workflow"]
return workflow

@classmethod
Expand Down
33 changes: 0 additions & 33 deletions mypy-stubs/rdflib/container.pyi

This file was deleted.

8 changes: 0 additions & 8 deletions mypy-stubs/rdflib/events.pyi

This file was deleted.

33 changes: 0 additions & 33 deletions mypy-stubs/rdflib/exceptions.pyi

This file was deleted.

5 changes: 0 additions & 5 deletions mypy-stubs/rdflib/paths.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ class Path:
__truediv__: Callable[[Path, Union["URIRef", "Path"]], "SequencePath"]
__mul__: Callable[[Path, str], "MulPath"]
def __hash__(self) -> int: ...
def __eq__(self, other: Any) -> bool: ...
def __lt__(self, other: Any) -> bool: ...
def __le__(self, other: Any) -> bool: ...
def __ne__(self, other: Any) -> bool: ...
def __gt__(self, other: Any) -> bool: ...
def __ge__(self, other: Any) -> bool: ...

class InvPath(Path): ...
class SequencePath(Path): ...
Expand Down
12 changes: 1 addition & 11 deletions mypy-stubs/rdflib/plugins/parsers/notation3.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
# Stubs for rdflib.plugins.parsers.notation3 (Python 3.5)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Any

class BadSyntax(SyntaxError):
lines = ... # type: Any
def __init__(self, uri: Any, lines: Any, argstr: Any, i: Any, why: Any): ...
@property
def message(self) -> Any: ...
class BadSyntax(SyntaxError): ...
24 changes: 12 additions & 12 deletions mypy-stubs/rdflib/query.pyi
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
from io import BufferedIOBase
from typing import Any, Dict, Iterator, List, Optional, Tuple, overload
from typing import IO, Any, Dict, Iterator, List, Mapping, Optional, Tuple, overload

from rdflib import URIRef, Variable
from rdflib.term import Identifier
from typing_extensions import SupportsIndex

class ResultRow: # Tuple[Variable, URIRef]):
class ResultRow(Tuple["Identifier", ...]):
def __new__(
cls, values: Dict[Variable, URIRef], labels: List[Variable]
cls, values: Mapping[Variable, Identifier], labels: List[Variable]
) -> ResultRow: ...
def __getattr__(self, name: str) -> Any: ...
def __getattr__(self, name: str) -> Identifier: ...
@overload
def __getitem__(self, name: str) -> URIRef: ...
def __getitem__(self, name: str) -> Identifier: ...
@overload
def __getitem__(self, __x: SupportsIndex) -> Variable | URIRef: ...
def __getitem__(self, __x: SupportsIndex) -> Identifier: ...
@overload
def __getitem__(self, __x: slice) -> Tuple[Variable | URIRef, ...]: ...
def get(self, name: str, default: Any | None = ...) -> URIRef: ...
def asdict(self) -> Dict[Variable, URIRef]: ...
def __getitem__(self, __x: slice) -> Tuple[Identifier, ...]: ...
def get(self, name: str, default: Any | None = ...) -> Identifier: ...
def asdict(self) -> Dict[str, Identifier]: ...

class Result:
type: Any
Expand All @@ -28,14 +28,14 @@ class Result:
def __iter__(self) -> Iterator[bool | ResultRow]: ...
@staticmethod
def parse(
source: str | None = ...,
source: IO[Any] | None = ...,
format: str | None = ...,
content_type: str | None = ...,
**kwargs: Any
) -> Result: ...
def serialize(
self,
destination: str | BufferedIOBase | None = ...,
destination: str | IO[Any] | None = ...,
encoding: str = ...,
format: str = ...,
**args: Any
Expand Down
11 changes: 0 additions & 11 deletions mypy-stubs/rdflib/serializer.pyi

This file was deleted.

53 changes: 0 additions & 53 deletions mypy-stubs/rdflib/store.pyi

This file was deleted.

14 changes: 4 additions & 10 deletions mypy-stubs/rdflib/term.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class Identifier(Node, str):
def eq(self, other: Any) -> bool: ...
def neq(self, other: Any) -> bool: ...

class URIRef(Identifier):
class IdentifiedNode(Identifier): ...

class URIRef(IdentifiedNode):
def toPython(self) -> str: ...
def n3(self, namespace_manager: Any | None = ...) -> str: ...
def defrag(self) -> "URIRef": ...
Expand All @@ -16,7 +18,7 @@ class URIRef(Identifier):
class Genid(URIRef): ...
class RDFLibGenid(Genid): ...

class BNode(Identifier):
class BNode(IdentifiedNode):
def toPython(self) -> str: ...
def n3(self, namespace_manager: Any | None = ...) -> str: ...
def skolemize(
Expand All @@ -36,14 +38,6 @@ class Literal(Identifier):
def n3(self, namespace_manager: Any | None = ...) -> str: ...
def toPython(self) -> str: ...

def bind(
datatype: str | None,
pythontype: type,
constructor: Callable[..., Any] | None = ...,
lexicalizer: Callable[..., Any] | None = ...,
datatype_specific: bool = ...,
) -> None: ...

class Variable(Identifier):
def toPython(self) -> str: ...
def n3(self, namespace_manager: Any | None = ...) -> str: ...
29 changes: 0 additions & 29 deletions mypy-stubs/rdflib/util.pyi

This file was deleted.

0 comments on commit cde1186

Please sign in to comment.