Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import from collections.abc when possible #240

Merged
merged 2 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/horizontal/emmo2meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
if sys.version_info >= (3, 7):
odict = dict
else:
from collections import OrderedDict as odict # noqa: F401
from collections.abc import OrderedDict as odict # noqa: F401
CasperWA marked this conversation as resolved.
Show resolved Hide resolved


class EMMO2Meta:
Expand Down
9 changes: 5 additions & 4 deletions ontopy/factpluspluswrapper/sync_factpp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import collections
from collections import defaultdict
from collections.abc import Sequence

import rdflib
from rdflib import URIRef, RDF, RDFS, OWL
Expand Down Expand Up @@ -39,7 +40,7 @@ def sync_reasoner_factpp(ontology_or_world=None, infer_property_values=False,
world = ontology_or_world
elif isinstance(ontology_or_world, Ontology):
world = ontology_or_world.world
elif isinstance(ontology_or_world, collections.Sequence):
elif isinstance(ontology_or_world, Sequence):
world = ontology_or_world[0].world
else:
world = owlready2.default_world
Expand Down Expand Up @@ -70,8 +71,8 @@ def sync_reasoner_factpp(ontology_or_world=None, infer_property_values=False,
print('*** Load inferred ontology')
# Check all rdfs:subClassOf relations in the inferred graph and add
# them to the world if they are missing
new_parents = collections.defaultdict(list)
new_equivs = collections.defaultdict(list)
new_parents = defaultdict(list)
new_equivs = defaultdict(list)
entity_2_type = {}

for s, p, o in g2.triples((None, None, None)):
Expand Down
4 changes: 2 additions & 2 deletions ontopy/nadict.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

NA stands for Nested and Attribute.
"""
import collections
from collections.abc import Mapping
import copy


Expand Down Expand Up @@ -66,7 +66,7 @@ def __setitem__(self, key, value):
else:
self._dict[key] = value
else:
if isinstance(value, collections.abc.Mapping):
if isinstance(value, Mapping):
self._dict[key] = NADict(value)
else:
self._dict[key] = value
Expand Down