Skip to content

Commit

Permalink
sync types with cwltool
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed Aug 3, 2022
1 parent fa1490f commit 2a5a0fc
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 210 deletions.
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.

87 changes: 77 additions & 10 deletions mypy-stubs/rdflib/graph.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
from typing import Any, Iterable, Iterator, List, Optional, Set, Tuple, Union, overload
import pathlib
from typing import (
IO,
Any,
Iterable,
Iterator,
List,
Optional,
Set,
Tuple,
Union,
overload,
)

from rdflib import query
from rdflib.collection import Collection
from rdflib.paths import Path
from rdflib.resource import Resource
from rdflib.term import BNode, Identifier, Node

Expand Down Expand Up @@ -37,6 +50,12 @@ class Graph(Node):
Optional[Identifier],
],
) -> Iterator[Tuple[Identifier, Identifier, Identifier]]: ...
def __getitem__(
self, item: slice | Path | Node
) -> Iterator[
Tuple[Identifier, Identifier, Identifier] | Tuple[Identifier, identifier] | Node
]: ...
def __contains__(self, triple: Any) -> bool: ...
def __add__(self, other: Any) -> Graph: ...
def set(self, triple: Any) -> None: ...
def subjects(
Expand All @@ -47,7 +66,7 @@ class Graph(Node):
) -> Iterable[Node]: ...
def objects(
self, subject: Optional[Any] = ..., predicate: Optional[Any] = ...
) -> Iterable[Node]: ...
) -> Iterable[Identifier]: ...
def subject_predicates(self, object: Optional[Any] = ...) -> None: ...
def subject_objects(self, predicate: Optional[Any] = ...) -> None: ...
def predicate_objects(self, subject: Optional[Any] = ...) -> None: ...
Expand Down Expand Up @@ -87,13 +106,61 @@ class Graph(Node):
) -> Any: ...
def namespaces(self) -> Iterator[Tuple[Any, Any]]: ...
def absolutize(self, uri: Any, defrag: int = ...) -> Any: ...

# no destination and non-None positional encoding
@overload
def serialize(
self,
destination: None,
format: str,
base: Optional[str],
encoding: str,
**args: Any,
) -> bytes: ...

# no destination and non-None keyword encoding
@overload
def serialize(
self,
destination: Optional[Any] = ...,
destination: None = ...,
format: str = ...,
base: Optional[Any] = ...,
encoding: Optional[Any] = ...,
**args: Any
base: Optional[str] = ...,
*,
encoding: str,
**args: Any,
) -> bytes: ...

# no destination and None encoding
@overload
def serialize(
self,
destination: None = ...,
format: str = ...,
base: Optional[str] = ...,
encoding: None = ...,
**args: Any,
) -> str: ...

# non-None destination
@overload
def serialize(
self,
destination: Union[str, pathlib.PurePath, IO[bytes]],
format: str = ...,
base: Optional[str] = ...,
encoding: Optional[str] = ...,
**args: Any,
) -> "Graph": ...

# fallback
@overload
def serialize(
self,
destination: Optional[Union[str, pathlib.PurePath, IO[bytes]]] = ...,
format: str = ...,
base: Optional[str] = ...,
encoding: Optional[str] = ...,
**args: Any,
) -> Union[bytes, str, "Graph"]: ...
def parse(
self,
Expand All @@ -103,7 +170,7 @@ class Graph(Node):
location: Optional[Any] = ...,
file: Optional[Any] = ...,
data: Optional[Any] = ...,
**args: Any
**args: Any,
) -> "Graph": ...
def load(
self, source: Any, publicID: Optional[Any] = ..., format: str = ...
Expand All @@ -116,7 +183,7 @@ class Graph(Node):
initNs: Optional[Any] = ...,
initBindings: Optional[Any] = ...,
use_store_provided: bool = ...,
**kwargs: Any
**kwargs: Any,
) -> query.Result: ...
def update(
self,
Expand All @@ -125,7 +192,7 @@ class Graph(Node):
initNs: Optional[Any] = ...,
initBindings: Optional[Any] = ...,
use_store_provided: bool = ...,
**kwargs: Any
**kwargs: Any,
) -> Any: ...
def n3(self) -> str: ...
def isomorphic(self, other: Any) -> bool: ...
Expand Down Expand Up @@ -177,7 +244,7 @@ class ConjunctiveGraph(Graph):
location: Optional[Any] = ...,
file: Optional[Any] = ...,
data: Optional[Any] = ...,
**args: Any
**args: Any,
) -> Graph: ...

class Seq:
Expand Down
6 changes: 5 additions & 1 deletion mypy-stubs/rdflib/namespace/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ class Namespace(str):
def title(self) -> URIRef: ...
def term(self, name: Any) -> URIRef: ...
def __getitem__(self, key: Any) -> URIRef: ...
def __getattr__(self, name: str) -> URIRef: ...

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

class DefinedNamespaceMeta(type): ...
class DefinedNamespaceMeta(type):
def __getitem__(cls, name: Any, default: Any | None = ...) -> URIRef: ...
def __getattr__(cls, name: Any) -> URIRef: ...
def __contains__(cls, item: Any) -> bool: ...

class DefinedNamespace(metaclass=DefinedNamespaceMeta):
def __init__(self) -> None: ...
Expand Down
24 changes: 24 additions & 0 deletions mypy-stubs/rdflib/paths.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from collections.abc import Generator
from typing import Any, Callable, Union

from rdflib.term import Node as Node
from rdflib.term import URIRef as URIRef

ZeroOrMore: str
OneOrMore: str
ZeroOrOne: str

class Path:
__or__: Callable[[Path, Union["URIRef", "Path"]], "AlternativePath"]
__invert__: Callable[[Path], "InvPath"]
__neg__: Callable[[Path], "NegatedPath"]
__truediv__: Callable[[Path, Union["URIRef", "Path"]], "SequencePath"]
__mul__: Callable[[Path, str], "MulPath"]
def __hash__(self) -> int: ...
def __lt__(self, other: Any) -> bool: ...

class InvPath(Path): ...
class SequencePath(Path): ...
class AlternativePath(Path): ...
class MulPath(Path): ...
class NegatedPath(Path): ...
2 changes: 0 additions & 2 deletions mypy-stubs/rdflib/plugin.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from typing import Any, Type, TypeVar

from rdflib.exceptions import Error

def register(name: str, kind: Any, module_path: str, class_name: str) -> None: ...

PluginT = TypeVar("PluginT")
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): ...
32 changes: 25 additions & 7 deletions mypy-stubs/rdflib/query.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
from io import BufferedIOBase
from typing import Any, Dict, Optional, Union
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["Identifier", ...]):
def __new__(
cls, values: Mapping[Variable, Identifier], labels: List[Variable]
) -> ResultRow: ...
def __getattr__(self, name: str) -> Identifier: ...
@overload
def __getitem__(self, name: str) -> Identifier: ...
@overload
def __getitem__(self, __x: SupportsIndex) -> Identifier: ...
@overload
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 @@ -8,16 +25,17 @@ class Result:
graph: Any
def __init__(self, type_: str) -> None: ...
bindings: Any
def __iter__(self) -> Iterator[bool | ResultRow]: ...
@staticmethod
def parse(
source: Any | None = ...,
format: Any | None = ...,
content_type: Any | None = ...,
source: IO[Any] | None = ...,
format: str | None = ...,
content_type: str | None = ...,
**kwargs: Any
) -> Any: ...
) -> Result: ...
def serialize(
self,
destination: Optional[Union[str, BufferedIOBase]] = ...,
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.

Loading

0 comments on commit 2a5a0fc

Please sign in to comment.