summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIwan Aucamp <aucampia@gmail.com>2023-04-10 12:08:55 +0200
committerGitHub <noreply@github.com>2023-04-10 12:08:55 +0200
commit20f1235d5f3b639a47cad59967fe93ed9e41dd90 (patch)
treecf9bf2744c8d836101bea0ef1a8472bcf59695fe
parent61f8a8d16a0812a6ebbe13ccaa3557f9fc4d0618 (diff)
downloadrdflib-20f1235d5f3b639a47cad59967fe93ed9e41dd90.tar.gz
refactor: eliminate inheritance from object (#2339)
This change removes the redundant inheritance from `object` (i.e. `class Foo(object): pass`) that is no longer needed in Python 3 and is a relic from Python 2.
-rw-r--r--rdflib/collection.py2
-rw-r--r--rdflib/compare.py6
-rw-r--r--rdflib/container.py2
-rw-r--r--rdflib/events.py4
-rw-r--r--rdflib/extras/describer.py4
-rw-r--r--rdflib/extras/infixowl.py4
-rw-r--r--rdflib/graph.py4
-rw-r--r--rdflib/namespace/__init__.py2
-rw-r--r--rdflib/parser.py2
-rw-r--r--rdflib/paths.py2
-rw-r--r--rdflib/plugins/parsers/jsonld.py2
-rwxr-xr-xrdflib/plugins/parsers/notation3.py4
-rw-r--r--rdflib/plugins/parsers/ntriples.py6
-rw-r--r--rdflib/plugins/parsers/rdfxml.py2
-rw-r--r--rdflib/plugins/serializers/jsonld.py2
-rw-r--r--rdflib/plugins/serializers/xmlwriter.py2
-rw-r--r--rdflib/plugins/shared/jsonld/context.py2
-rw-r--r--rdflib/plugins/sparql/aggregates.py4
-rw-r--r--rdflib/plugins/sparql/parserutils.py2
-rw-r--r--rdflib/plugins/sparql/sparql.py2
-rw-r--r--rdflib/plugins/stores/concurrent.py4
-rw-r--r--rdflib/plugins/stores/sparqlconnector.py2
-rw-r--r--rdflib/query.py12
-rw-r--r--rdflib/resource.py2
-rw-r--r--rdflib/store.py4
-rw-r--r--rdflib/term.py2
-rw-r--r--rdflib/tools/csv2rdf.py4
-rw-r--r--test/test_graph/test_batch_add.py2
-rw-r--r--test/test_nt_misc.py2
-rw-r--r--test/test_parsers/test_swap_n3.py2
-rw-r--r--test/test_serializers/test_prettyxml.py2
-rw-r--r--test/test_serializers/test_serializer_xml.py2
32 files changed, 50 insertions, 50 deletions
diff --git a/rdflib/collection.py b/rdflib/collection.py
index b9c76107..fd64ab20 100644
--- a/rdflib/collection.py
+++ b/rdflib/collection.py
@@ -11,7 +11,7 @@ if TYPE_CHECKING:
__all__ = ["Collection"]
-class Collection(object):
+class Collection:
__doc__ = """
See "Emulating container types":
https://docs.python.org/reference/datamodel.html#emulating-container-types
diff --git a/rdflib/compare.py b/rdflib/compare.py
index 4b8473c7..30f52d97 100644
--- a/rdflib/compare.py
+++ b/rdflib/compare.py
@@ -118,7 +118,7 @@ def _total_seconds(td):
return result
-class _runtime(object): # noqa: N801
+class _runtime: # noqa: N801
def __init__(self, label):
self.label = label
@@ -137,7 +137,7 @@ class _runtime(object): # noqa: N801
return wrapped_f
-class _call_count(object): # noqa: N801
+class _call_count: # noqa: N801
def __init__(self, label):
self.label = label
@@ -284,7 +284,7 @@ class Color:
_HashT = Callable[[], "HASH"]
-class _TripleCanonicalizer(object):
+class _TripleCanonicalizer:
def __init__(self, graph: Graph, hashfunc: _HashT = sha256):
self.graph = graph
diff --git a/rdflib/container.py b/rdflib/container.py
index b5c0ebd5..56554df0 100644
--- a/rdflib/container.py
+++ b/rdflib/container.py
@@ -6,7 +6,7 @@ from rdflib.term import BNode, URIRef
__all__ = ["Container", "Bag", "Seq", "Alt", "NoElementException"]
-class Container(object):
+class Container:
"""A class for constructing RDF containers, as per https://www.w3.org/TR/rdf11-mt/#rdf-containers
Basic usage, creating a ``Bag`` and adding to it::
diff --git a/rdflib/events.py b/rdflib/events.py
index e973c308..d0290d5c 100644
--- a/rdflib/events.py
+++ b/rdflib/events.py
@@ -26,7 +26,7 @@ fired:
__all__ = ["Event", "Dispatcher"]
-class Event(object):
+class Event:
"""
An event is a container for attributes. The source of an event
creates this object, or a subclass, gives it any kind of data that
@@ -47,7 +47,7 @@ class Event(object):
return "<rdflib.events.Event %s>" % ([a for a in attrs],)
-class Dispatcher(object):
+class Dispatcher:
"""
An object that can dispatch events to a privately managed group of
subscribers.
diff --git a/rdflib/extras/describer.py b/rdflib/extras/describer.py
index aa318c46..02397055 100644
--- a/rdflib/extras/describer.py
+++ b/rdflib/extras/describer.py
@@ -20,7 +20,7 @@ Full example in the ``to_rdf`` method below::
>>>
>>> CV = Namespace("http://purl.org/captsolo/resume-rdf/0.2/cv#")
>>>
- >>> class Person(object):
+ >>> class Person:
... def __init__(self):
... self.first_name = u"Some"
... self.last_name = u"Body"
@@ -112,7 +112,7 @@ from rdflib.namespace import RDF
from rdflib.term import BNode, Identifier, Literal, URIRef
-class Describer(object):
+class Describer:
def __init__(self, graph=None, about=None, base=None):
if graph is None:
graph = Graph()
diff --git a/rdflib/extras/infixowl.py b/rdflib/extras/infixowl.py
index fc3e24ae..9c75345b 100644
--- a/rdflib/extras/infixowl.py
+++ b/rdflib/extras/infixowl.py
@@ -357,7 +357,7 @@ class TermDeletionHelper:
return _remover
-class Individual(object):
+class Individual:
"""
A typed individual
"""
@@ -1382,7 +1382,7 @@ class Class(AnnotatableTerms):
) + klassdescr
-class OWLRDFListProxy(object):
+class OWLRDFListProxy:
def __init__(self, rdf_list, members=None, graph=None):
if graph:
self.graph = graph
diff --git a/rdflib/graph.py b/rdflib/graph.py
index 809241df..c6f0fd36 100644
--- a/rdflib/graph.py
+++ b/rdflib/graph.py
@@ -2588,7 +2588,7 @@ class QuotedGraph(Graph):
rdflib.term._ORDERING[QuotedGraph] = 11
-class Seq(object):
+class Seq:
"""Wrapper around an RDF Seq resource
It implements a container type in Python with the order of the items
@@ -2894,7 +2894,7 @@ def _assertnode(*terms: Any) -> bool:
return True
-class BatchAddGraph(object):
+class BatchAddGraph:
"""
Wrapper around graph that turns batches of calls to Graph's add
(and optionally, addN) into calls to batched calls to addN`.
diff --git a/rdflib/namespace/__init__.py b/rdflib/namespace/__init__.py
index 57f52f33..618cab78 100644
--- a/rdflib/namespace/__init__.py
+++ b/rdflib/namespace/__init__.py
@@ -348,7 +348,7 @@ if TYPE_CHECKING:
_with_bind_override_fix = True
-class NamespaceManager(object):
+class NamespaceManager:
"""Class for managing prefix => namespace mappings
This class requires an RDFlib Graph as an input parameter and may optionally have
diff --git a/rdflib/parser.py b/rdflib/parser.py
index 6f23dd34..6cf6f1da 100644
--- a/rdflib/parser.py
+++ b/rdflib/parser.py
@@ -53,7 +53,7 @@ __all__ = [
]
-class Parser(object):
+class Parser:
__slots__ = ()
def __init__(self):
diff --git a/rdflib/paths.py b/rdflib/paths.py
index 6ca42d74..df713617 100644
--- a/rdflib/paths.py
+++ b/rdflib/paths.py
@@ -214,7 +214,7 @@ ZeroOrOne = "?"
@total_ordering
-class Path(object):
+class Path:
__or__: Callable[["Path", Union["URIRef", "Path"]], "AlternativePath"]
__invert__: Callable[["Path"], "InvPath"]
__neg__: Callable[["Path"], "NegatedPath"]
diff --git a/rdflib/plugins/parsers/jsonld.py b/rdflib/plugins/parsers/jsonld.py
index 716b80f4..4eb05fce 100644
--- a/rdflib/plugins/parsers/jsonld.py
+++ b/rdflib/plugins/parsers/jsonld.py
@@ -138,7 +138,7 @@ def to_rdf(
return parser.parse(data, context, dataset)
-class Parser(object):
+class Parser:
def __init__(
self, generalized_rdf: bool = False, allow_lists_of_lists: Optional[bool] = None
):
diff --git a/rdflib/plugins/parsers/notation3.py b/rdflib/plugins/parsers/notation3.py
index 25ea0c74..08798076 100755
--- a/rdflib/plugins/parsers/notation3.py
+++ b/rdflib/plugins/parsers/notation3.py
@@ -1773,7 +1773,7 @@ class BadSyntax(SyntaxError):
###############################################################################
-class Formula(object):
+class Formula:
number = 0
def __init__(self, parent: Graph):
@@ -1815,7 +1815,7 @@ class Formula(object):
r_hibyte = re.compile(r"([\x80-\xff])")
-class RDFSink(object):
+class RDFSink:
def __init__(self, graph: Graph):
self.rootFormula: Optional[Formula] = None
self.uuid = uuid4().hex
diff --git a/rdflib/plugins/parsers/ntriples.py b/rdflib/plugins/parsers/ntriples.py
index 564a2cf1..09656faf 100644
--- a/rdflib/plugins/parsers/ntriples.py
+++ b/rdflib/plugins/parsers/ntriples.py
@@ -60,7 +60,7 @@ bufsiz = 2048
validate = False
-class DummySink(object):
+class DummySink:
def __init__(self):
self.length = 0
@@ -126,7 +126,7 @@ def uriquote(uri: str) -> str:
_BNodeContextType = MutableMapping[str, bNode]
-class W3CNTriplesParser(object):
+class W3CNTriplesParser:
"""An N-Triples Parser.
This is a legacy-style Triples parser for NTriples provided by W3C
Usage::
@@ -334,7 +334,7 @@ class W3CNTriplesParser(object):
return False
-class NTGraphSink(object):
+class NTGraphSink:
__slots__ = ("g",)
def __init__(self, graph: "Graph"):
diff --git a/rdflib/plugins/parsers/rdfxml.py b/rdflib/plugins/parsers/rdfxml.py
index 76775f00..03650fc9 100644
--- a/rdflib/plugins/parsers/rdfxml.py
+++ b/rdflib/plugins/parsers/rdfxml.py
@@ -95,7 +95,7 @@ class BagID(URIRef):
return RDFNS["_%s" % self.li]
-class ElementHandler(object):
+class ElementHandler:
__slots__ = [
"start",
"char",
diff --git a/rdflib/plugins/serializers/jsonld.py b/rdflib/plugins/serializers/jsonld.py
index e9ff401b..e5d9b038 100644
--- a/rdflib/plugins/serializers/jsonld.py
+++ b/rdflib/plugins/serializers/jsonld.py
@@ -138,7 +138,7 @@ def from_rdf(
return result
-class Converter(object):
+class Converter:
def __init__(self, context, use_native_types, use_rdf_type):
self.context = context
self.use_native_types = context.active or use_native_types
diff --git a/rdflib/plugins/serializers/xmlwriter.py b/rdflib/plugins/serializers/xmlwriter.py
index 9ed10f48..88cebded 100644
--- a/rdflib/plugins/serializers/xmlwriter.py
+++ b/rdflib/plugins/serializers/xmlwriter.py
@@ -6,7 +6,7 @@ __all__ = ["XMLWriter"]
ESCAPE_ENTITIES = {"\r": "&#13;"}
-class XMLWriter(object):
+class XMLWriter:
def __init__(self, stream, namespace_manager, encoding=None, decl=1, extra_ns=None):
encoding = encoding or "utf-8"
encoder, decoder, stream_reader, stream_writer = codecs.lookup(encoding)
diff --git a/rdflib/plugins/shared/jsonld/context.py b/rdflib/plugins/shared/jsonld/context.py
index b19f6673..2f6cedbd 100644
--- a/rdflib/plugins/shared/jsonld/context.py
+++ b/rdflib/plugins/shared/jsonld/context.py
@@ -69,7 +69,7 @@ UNDEF = Defined(0)
URI_GEN_DELIMS = (":", "/", "?", "#", "[", "]", "@")
-class Context(object):
+class Context:
def __init__(
self,
source: Optional[Any] = None,
diff --git a/rdflib/plugins/sparql/aggregates.py b/rdflib/plugins/sparql/aggregates.py
index fb2dffed..67e143a7 100644
--- a/rdflib/plugins/sparql/aggregates.py
+++ b/rdflib/plugins/sparql/aggregates.py
@@ -30,7 +30,7 @@ Aggregation functions
"""
-class Accumulator(object):
+class Accumulator:
"""abstract base class for different aggregation functions"""
def __init__(self, aggregation: CompValue):
@@ -268,7 +268,7 @@ class GroupConcat(Accumulator):
return Literal(self.separator.join(str(v) for v in self.value))
-class Aggregator(object):
+class Aggregator:
"""combines different Accumulator objects"""
accumulator_classes = {
diff --git a/rdflib/plugins/sparql/parserutils.py b/rdflib/plugins/sparql/parserutils.py
index 1f4109c8..b625f364 100644
--- a/rdflib/plugins/sparql/parserutils.py
+++ b/rdflib/plugins/sparql/parserutils.py
@@ -99,7 +99,7 @@ def value(
return val
-class ParamValue(object):
+class ParamValue:
"""
The result of parsing a Param
This just keeps the name/value
diff --git a/rdflib/plugins/sparql/sparql.py b/rdflib/plugins/sparql/sparql.py
index 0332d4e7..64230a64 100644
--- a/rdflib/plugins/sparql/sparql.py
+++ b/rdflib/plugins/sparql/sparql.py
@@ -246,7 +246,7 @@ class FrozenBindings(FrozenDict):
return FrozenBindings(self.ctx, (x for x in self.items() if x[0] in these))
-class QueryContext(object):
+class QueryContext:
"""
Query context - passed along when evaluating the query
"""
diff --git a/rdflib/plugins/stores/concurrent.py b/rdflib/plugins/stores/concurrent.py
index cdf41ba0..c0786795 100644
--- a/rdflib/plugins/stores/concurrent.py
+++ b/rdflib/plugins/stores/concurrent.py
@@ -1,7 +1,7 @@
from threading import Lock
-class ResponsibleGenerator(object):
+class ResponsibleGenerator:
"""A generator that will help clean up when it is done being used."""
__slots__ = ["cleanup", "gen"]
@@ -20,7 +20,7 @@ class ResponsibleGenerator(object):
return next(self.gen)
-class ConcurrentStore(object):
+class ConcurrentStore:
def __init__(self, store):
self.store = store
diff --git a/rdflib/plugins/stores/sparqlconnector.py b/rdflib/plugins/stores/sparqlconnector.py
index 79f9c54a..faf57538 100644
--- a/rdflib/plugins/stores/sparqlconnector.py
+++ b/rdflib/plugins/stores/sparqlconnector.py
@@ -30,7 +30,7 @@ _response_mime_types = {
}
-class SPARQLConnector(object):
+class SPARQLConnector:
"""
this class deals with nitty gritty details of talking to a SPARQL server
"""
diff --git a/rdflib/query.py b/rdflib/query.py
index 155c490e..e9c18901 100644
--- a/rdflib/query.py
+++ b/rdflib/query.py
@@ -40,7 +40,7 @@ if TYPE_CHECKING:
from rdflib.term import Identifier, Variable
-class Processor(object):
+class Processor:
"""
Query plugin interface.
@@ -64,7 +64,7 @@ class Processor(object):
pass
-class UpdateProcessor(object):
+class UpdateProcessor:
"""
Update plugin interface.
@@ -93,7 +93,7 @@ class ResultException(Exception):
pass
-class EncodeOnlyUnicode(object):
+class EncodeOnlyUnicode:
"""
This is a crappy work-around for
http://bugs.python.org/issue11649
@@ -202,7 +202,7 @@ class ResultRow(Tuple["Identifier", ...]):
return dict((v, self[v]) for v in self.labels if self[v] is not None)
-class Result(object):
+class Result:
"""
A common class for representing query result.
@@ -413,7 +413,7 @@ class Result(object):
return False
-class ResultParser(object):
+class ResultParser:
def __init__(self):
pass
@@ -423,7 +423,7 @@ class ResultParser(object):
pass # abstract
-class ResultSerializer(object):
+class ResultSerializer:
def __init__(self, result: Result):
self.result = result
diff --git a/rdflib/resource.py b/rdflib/resource.py
index 49c196dd..0620c13d 100644
--- a/rdflib/resource.py
+++ b/rdflib/resource.py
@@ -293,7 +293,7 @@ from rdflib.term import BNode, Node, URIRef
__all__ = ["Resource"]
-class Resource(object):
+class Resource:
def __init__(self, graph, subject):
self._graph = graph
self._identifier = subject
diff --git a/rdflib/store.py b/rdflib/store.py
index ca6f9261..e3c9f7ab 100644
--- a/rdflib/store.py
+++ b/rdflib/store.py
@@ -113,7 +113,7 @@ class TripleRemovedEvent(Event):
"""
-class NodePickler(object):
+class NodePickler:
def __init__(self) -> None:
self._objects: Dict[str, Any] = {}
self._ids: Dict[Any, str] = {}
@@ -165,7 +165,7 @@ class NodePickler(object):
self._get_object = self._objects.__getitem__
-class Store(object):
+class Store:
# Properties
context_aware: bool = False
formula_aware: bool = False
diff --git a/rdflib/term.py b/rdflib/term.py
index a42d524a..bdfbec11 100644
--- a/rdflib/term.py
+++ b/rdflib/term.py
@@ -119,7 +119,7 @@ def _is_valid_unicode(value: Union[str, bytes]) -> bool:
return True
-class Node(object):
+class Node:
"""
A Node in the Graph.
"""
diff --git a/rdflib/tools/csv2rdf.py b/rdflib/tools/csv2rdf.py
index 2bf7dc86..267483ed 100644
--- a/rdflib/tools/csv2rdf.py
+++ b/rdflib/tools/csv2rdf.py
@@ -139,7 +139,7 @@ def prefixuri(x, prefix, class_=None):
# meta-language for config
-class NodeMaker(object):
+class NodeMaker:
def range(self):
return rdflib.RDFS.Literal
@@ -296,7 +296,7 @@ def column(v):
return eval(v, config_functions)
-class CSV2RDF(object):
+class CSV2RDF:
def __init__(self):
self.CLASS = None
self.BASE = None
diff --git a/test/test_graph/test_batch_add.py b/test/test_graph/test_batch_add.py
index b8d037e9..112a8903 100644
--- a/test/test_graph/test_batch_add.py
+++ b/test/test_graph/test_batch_add.py
@@ -72,7 +72,7 @@ class TestBatchAddGraph:
assert 10 == len(g)
def test_addN_batching_addN(self):
- class MockGraph(object):
+ class MockGraph:
def __init__(self):
self.counts = []
diff --git a/test/test_nt_misc.py b/test/test_nt_misc.py
index f2b650e7..90a6e93a 100644
--- a/test/test_nt_misc.py
+++ b/test/test_nt_misc.py
@@ -268,7 +268,7 @@ class TestBNodeContext:
assert len(my_sink.subs) == 1
-class FakeSink(object):
+class FakeSink:
def __init__(self):
self.subs = set()
diff --git a/test/test_parsers/test_swap_n3.py b/test/test_parsers/test_swap_n3.py
index dc8d9a8a..cebb55ad 100644
--- a/test/test_parsers/test_swap_n3.py
+++ b/test/test_parsers/test_swap_n3.py
@@ -60,7 +60,7 @@ skiptests = [
]
-class Envelope(object):
+class Envelope:
def __init__(self, n, f):
self.name = n
self.file = f
diff --git a/test/test_serializers/test_prettyxml.py b/test/test_serializers/test_prettyxml.py
index 4d406a6e..0084aa24 100644
--- a/test/test_serializers/test_prettyxml.py
+++ b/test/test_serializers/test_prettyxml.py
@@ -7,7 +7,7 @@ from rdflib.plugins.serializers.rdfxml import PrettyXMLSerializer
from rdflib.term import BNode, Literal, URIRef
-class SerializerTestBase(object):
+class SerializerTestBase:
repeats = 8
def setup_method(self):
diff --git a/test/test_serializers/test_serializer_xml.py b/test/test_serializers/test_serializer_xml.py
index bac0169d..ad901293 100644
--- a/test/test_serializers/test_serializer_xml.py
+++ b/test/test_serializers/test_serializer_xml.py
@@ -6,7 +6,7 @@ from rdflib.plugins.serializers.rdfxml import XMLSerializer
from rdflib.term import BNode, URIRef
-class SerializerTestBase(object):
+class SerializerTestBase:
repeats = 8
def setup_method(self):