Skip to content

Commit

Permalink
Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks"
Browse files Browse the repository at this point in the history
This reverts commit 1e69cb6.
  • Loading branch information
edmondchuc committed Mar 12, 2024
1 parent 1e69cb6 commit c593a2b
Show file tree
Hide file tree
Showing 100 changed files with 716 additions and 1,789 deletions.
1 change: 0 additions & 1 deletion examples/berkeleydb_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* loads multiple graphs downloaded from GitHub into a BerkeleyDB-baked graph stored in the folder gsq_vocabs.
* does not delete the DB at the end so you can see it on disk
"""

import os
import tempfile

Expand Down
1 change: 1 addition & 0 deletions examples/custom_datatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
mappings between literal datatypes and Python objects
"""


from rdflib import XSD, Graph, Literal, Namespace, term

if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions examples/custom_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
}
"""


from pathlib import Path

import rdflib
Expand Down
7 changes: 4 additions & 3 deletions examples/jsonld_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@
"schema": "https://schema.org/"
}
"""

# import RDFLib and other things
try:
from rdflib import Graph
except ModuleNotFoundError:
import sys
from pathlib import Path

sys.path.append(str(Path(__file__).parent.parent))
from rdflib import Graph

Expand Down Expand Up @@ -178,7 +176,10 @@

# 2.3 Compact the JSON-LD by supplying own context
# We now override RDFLib's namespace prefixes by supplying our own context information
context = {"sdo": "https://schema.org/", "dct": "http://purl.org/dc/terms/"}
context = {
"sdo": "https://schema.org/",
"dct": "http://purl.org/dc/terms/"
}

# Now when we serialise the RDF data, this context can be used to overwrite the default RDFLib one. auto_compact need not be specified
print(g.serialize(format="json-ld", context=context))
Expand Down
1 change: 0 additions & 1 deletion examples/secure_with_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
The code in the example then verifies that the audit hook is blocking access to
URLs and files as expected.
"""

from __future__ import annotations

import logging
Expand Down
1 change: 0 additions & 1 deletion examples/secure_with_urlopen.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
This example demonstrates how to use a custom global URL opener installed with `urllib.request.install_opener` to block access to URLs.
"""

from __future__ import annotations

import http.client
Expand Down
1 change: 0 additions & 1 deletion rdflib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
True
"""

import logging
import sys
from importlib import metadata
Expand Down
1 change: 0 additions & 1 deletion rdflib/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
_:cb558f30e21ddfc05ca53108348338ade8
<http://example.org/ns#label> "B" .
"""

from __future__ import annotations

# TODO:
Expand Down
1 change: 0 additions & 1 deletion rdflib/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
TODO:
"""

from __future__ import annotations

__all__ = [
Expand Down
1 change: 0 additions & 1 deletion rdflib/extras/external_graph_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
networkx or graph_tool are available and they would err otherwise.
see ../../test/test_extras_external_graph_libs.py for conditional tests
"""

from __future__ import annotations

import logging
Expand Down
1 change: 0 additions & 1 deletion rdflib/extras/infixowl.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
>>> print(g.serialize(format='pretty-xml')) # doctest: +SKIP
"""

from __future__ import annotations

import itertools
Expand Down
1 change: 0 additions & 1 deletion rdflib/extras/shacl.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Utilities for interacting with SHACL Shapes Graphs more easily.
"""

from __future__ import annotations

from typing import Optional, Union
Expand Down
84 changes: 56 additions & 28 deletions rdflib/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,19 +558,22 @@ def remove(self: _GraphT, triple: _TriplePatternType) -> _GraphT:
def triples(
self,
triple: _TriplePatternType,
) -> Generator[_TripleType, None, None]: ...
) -> Generator[_TripleType, None, None]:
...

@overload
def triples(
self,
triple: _TriplePathPatternType,
) -> Generator[_TriplePathType, None, None]: ...
) -> Generator[_TriplePathType, None, None]:
...

@overload
def triples(
self,
triple: _TripleSelectorType,
) -> Generator[_TripleOrTriplePathType, None, None]: ...
) -> Generator[_TripleOrTriplePathType, None, None]:
...

def triples(
self,
Expand Down Expand Up @@ -957,7 +960,8 @@ def value(
object: Optional[_ObjectType] = ...,
default: Optional[Node] = ...,
any: bool = ...,
) -> None: ...
) -> None:
...

@overload
def value(
Expand All @@ -967,7 +971,8 @@ def value(
object: None = ...,
default: Optional[Node] = ...,
any: bool = ...,
) -> None: ...
) -> None:
...

@overload
def value(
Expand All @@ -977,7 +982,8 @@ def value(
object: None = ...,
default: Optional[Node] = ...,
any: bool = ...,
) -> None: ...
) -> None:
...

@overload
def value(
Expand All @@ -987,7 +993,8 @@ def value(
object: Optional[_ObjectType] = ...,
default: Optional[Node] = ...,
any: bool = ...,
) -> Optional[Node]: ...
) -> Optional[Node]:
...

def value(
self,
Expand Down Expand Up @@ -1225,7 +1232,8 @@ def serialize(
base: Optional[str],
encoding: str,
**args: Any,
) -> bytes: ...
) -> bytes:
...

# no destination and non-None keyword encoding
@overload
Expand All @@ -1237,7 +1245,8 @@ def serialize(
*,
encoding: str,
**args: Any,
) -> bytes: ...
) -> bytes:
...

# no destination and None encoding
@overload
Expand All @@ -1248,7 +1257,8 @@ def serialize(
base: Optional[str] = ...,
encoding: None = ...,
**args: Any,
) -> str: ...
) -> str:
...

# non-None destination
@overload
Expand All @@ -1259,7 +1269,8 @@ def serialize(
base: Optional[str] = ...,
encoding: Optional[str] = ...,
**args: Any,
) -> Graph: ...
) -> Graph:
...

# fallback
@overload
Expand All @@ -1270,7 +1281,8 @@ def serialize(
base: Optional[str] = ...,
encoding: Optional[str] = ...,
**args: Any,
) -> Union[bytes, str, Graph]: ...
) -> Union[bytes, str, Graph]:
...

def serialize(
self: _GraphT,
Expand Down Expand Up @@ -1920,42 +1932,48 @@ def _spoc(
self,
triple_or_quad: _QuadType,
default: bool = False,
) -> _QuadType: ...
) -> _QuadType:
...

@overload
def _spoc(
self,
triple_or_quad: Union[_TripleType, _OptionalQuadType],
default: bool = False,
) -> _OptionalQuadType: ...
) -> _OptionalQuadType:
...

@overload
def _spoc(
self,
triple_or_quad: None,
default: bool = False,
) -> Tuple[None, None, None, Optional[Graph]]: ...
) -> Tuple[None, None, None, Optional[Graph]]:
...

@overload
def _spoc(
self,
triple_or_quad: Optional[_TripleOrQuadPatternType],
default: bool = False,
) -> _QuadPatternType: ...
) -> _QuadPatternType:
...

@overload
def _spoc(
self,
triple_or_quad: _TripleOrQuadSelectorType,
default: bool = False,
) -> _QuadSelectorType: ...
) -> _QuadSelectorType:
...

@overload
def _spoc(
self,
triple_or_quad: Optional[_TripleOrQuadSelectorType],
default: bool = False,
) -> _QuadSelectorType: ...
) -> _QuadSelectorType:
...

def _spoc(
self,
Expand Down Expand Up @@ -2004,10 +2022,12 @@ def add(
return self

@overload
def _graph(self, c: Union[Graph, _ContextIdentifierType, str]) -> Graph: ...
def _graph(self, c: Union[Graph, _ContextIdentifierType, str]) -> Graph:
...

@overload
def _graph(self, c: None) -> None: ...
def _graph(self, c: None) -> None:
...

def _graph(
self, c: Optional[Union[Graph, _ContextIdentifierType, str]]
Expand Down Expand Up @@ -2049,21 +2069,24 @@ def triples(
self,
triple_or_quad: _TripleOrQuadPatternType,
context: Optional[_ContextType] = ...,
) -> Generator[_TripleType, None, None]: ...
) -> Generator[_TripleType, None, None]:
...

@overload
def triples(
self,
triple_or_quad: _TripleOrQuadPathPatternType,
context: Optional[_ContextType] = ...,
) -> Generator[_TriplePathType, None, None]: ...
) -> Generator[_TriplePathType, None, None]:
...

@overload
def triples(
self,
triple_or_quad: _TripleOrQuadSelectorType,
context: Optional[_ContextType] = ...,
) -> Generator[_TripleOrTriplePathType, None, None]: ...
) -> Generator[_TripleOrTriplePathType, None, None]:
...

def triples(
self,
Expand Down Expand Up @@ -2738,19 +2761,22 @@ def remove(self, triple: _TripleOrOptionalQuadType) -> NoReturn: # type: ignore
def triples(
self,
triple: _TriplePatternType,
) -> Generator[_TripleType, None, None]: ...
) -> Generator[_TripleType, None, None]:
...

@overload
def triples(
self,
triple: _TriplePathPatternType,
) -> Generator[_TriplePathType, None, None]: ...
) -> Generator[_TriplePathType, None, None]:
...

@overload
def triples(
self,
triple: _TripleSelectorType,
) -> Generator[_TripleOrTriplePathType, None, None]: ...
) -> Generator[_TripleOrTriplePathType, None, None]:
...

def triples(
self,
Expand Down Expand Up @@ -2891,11 +2917,13 @@ def __reduce__(self) -> NoReturn:


@overload
def _assertnode(*terms: Node) -> te.Literal[True]: ...
def _assertnode(*terms: Node) -> te.Literal[True]:
...


@overload
def _assertnode(*terms: Any) -> bool: ...
def _assertnode(*terms: Any) -> bool:
...


def _assertnode(*terms: Any) -> bool:
Expand Down
Loading

0 comments on commit c593a2b

Please sign in to comment.