diff options
author | Iwan Aucamp <aucampia@gmail.com> | 2023-04-10 12:07:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-10 12:07:29 +0200 |
commit | 61f8a8d16a0812a6ebbe13ccaa3557f9fc4d0618 (patch) | |
tree | b1ba70bd927b9021a7f2ad9790673238ab7de036 | |
parent | b2f3987240ebb9edf03fea9bd94f8760ef99f419 (diff) | |
download | rdflib-61f8a8d16a0812a6ebbe13ccaa3557f9fc4d0618.tar.gz |
refactor: narrow imports (#2338)
This change narrows import so that things are imported from the Python module
where they are defined instead of importing them from a module that re-exports
them, e.g. change import of `Graph` to import from the `rdflib.graph` module
instead of from the `rdflib` module. This helps avoid problems with circular
imports.
-rw-r--r-- | rdflib/extras/infixowl.py | 5 | ||||
-rw-r--r-- | rdflib/plugins/sparql/parserutils.py | 3 | ||||
-rw-r--r-- | rdflib/void.py | 3 |
3 files changed, 5 insertions, 6 deletions
diff --git a/rdflib/extras/infixowl.py b/rdflib/extras/infixowl.py index f4daab77..fc3e24ae 100644 --- a/rdflib/extras/infixowl.py +++ b/rdflib/extras/infixowl.py @@ -110,11 +110,10 @@ Python import itertools import logging -from rdflib import OWL, RDF, RDFS, XSD, BNode, Literal, Namespace, URIRef, Variable from rdflib.collection import Collection from rdflib.graph import Graph -from rdflib.namespace import NamespaceManager -from rdflib.term import Identifier +from rdflib.namespace import OWL, RDF, RDFS, XSD, Namespace, NamespaceManager +from rdflib.term import BNode, Identifier, Literal, URIRef, Variable from rdflib.util import first logger = logging.getLogger(__name__) diff --git a/rdflib/plugins/sparql/parserutils.py b/rdflib/plugins/sparql/parserutils.py index 5b3df78b..1f4109c8 100644 --- a/rdflib/plugins/sparql/parserutils.py +++ b/rdflib/plugins/sparql/parserutils.py @@ -16,8 +16,7 @@ from typing import ( from pyparsing import ParseResults, TokenConverter, originalTextFor -from rdflib import BNode, Variable -from rdflib.term import Identifier +from rdflib.term import BNode, Identifier, Variable if TYPE_CHECKING: from rdflib.plugins.sparql.sparql import FrozenBindings diff --git a/rdflib/void.py b/rdflib/void.py index ff81e247..8a123e5f 100644 --- a/rdflib/void.py +++ b/rdflib/void.py @@ -1,7 +1,8 @@ import collections -from rdflib import Graph, Literal, URIRef +from rdflib.graph import Graph from rdflib.namespace import RDF, VOID +from rdflib.term import Literal, URIRef def generateVoID( # noqa: N802 |