Skip to content

Commit

Permalink
Merge pull request #535 from emmo-repo/flb/fix_to_pylint2.15.4
Browse files Browse the repository at this point in the history
Flb/fix to pylint2.15.4
  • Loading branch information
francescalb authored Feb 4, 2023
2 parents 751a8d5 + 3a0464c commit f88f721
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 42 deletions.
2 changes: 1 addition & 1 deletion demo/horizontal/emmo2meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def get_properties(self, cls): # pylint: disable=too-many-locals
props = []
dimindices = {}
propnames = set()
types = dict(Integer="int", Real="double", String="string")
types = {"Integer": "int", "Real": "double", "String": "string"}

def get_dim(restriction, name, descr=None):
"""Returns dimension index corresponding to dimension name `name`
Expand Down
2 changes: 1 addition & 1 deletion ontopy/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def __init__( # pylint: disable=too-many-arguments,too-many-locals
self.edges = set()
else:
if ontology != graph.ontology:
ValueError(
raise ValueError(
"the same ontology must be used when extending a graph"
)
self.dot = graph.dot.copy()
Expand Down
69 changes: 34 additions & 35 deletions ontopy/ontodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,20 @@ class OntoDoc:
annotation values.
"""

_markdown_style = dict(
sep="\n",
figwidth="{{ width={width:.0f}px }}",
figure="![{caption}]({path}){figwidth}\n",
header="\n{:#<{level}} {label}",
link="[{name}]({lowerurl})",
point=" - {point}\n",
points="\n\n{points}\n",
annotation="**{key}:** {value}\n",
substitutions=[],
)
_markdown_style = {
"sep": "\n",
"figwidth": "{{ width={width:.0f}px }}",
"figure": "![{caption}]({path}){figwidth}\n",
"header": "\n{:#<{level}} {label}",
"link": "[{name}]({lowerurl})",
"point": " - {point}\n",
"points": "\n\n{points}\n",
"annotation": "**{key}:** {value}\n",
"substitutions": [],
}
# Extra style settings for markdown+tex (e.g. pdf generation with pandoc)
_markdown_tex_extra_style = dict(
substitutions=[
_markdown_tex_extra_style = {
"substitutions": [
# logic/math symbols
("\u2200", r"$\\forall$"),
("\u2203", r"$\\exists$"),
Expand Down Expand Up @@ -132,17 +132,17 @@ class OntoDoc:
("\u014d", r"$\\bar{\\mathrm{o}}$"),
("\u1f45", r"$\\acute{o}$"), # no \omicron
],
)
_html_style = dict(
sep="<p>\n",
figwidth='width="{width:.0f}"',
figure='<img src="{path}" alt="{caption}"{figwidth}>',
header='<h{level} id="{lowerlabel}">{label}</h{level}>',
link='<a href="{lowerurl}">{name}</a>',
point=" <li>{point}</li>\n",
points=" <ul>\n {points}\n </ul>\n",
annotation=" <dd><strong>{key}:</strong>\n{value} </dd>\n",
substitutions=[
}
_html_style = {
"sep": "<p>\n",
"figwidth": 'width="{width:.0f}"',
"figure": '<img src="{path}" alt="{caption}"{figwidth}>',
"header": '<h{level} id="{lowerlabel}">{label}</h{level}>',
"link": '<a href="{lowerurl}">{name}</a>',
"point": " <li>{point}</li>\n",
"points": " <ul>\n {points}\n </ul>\n",
"annotation": " <dd><strong>{key}:</strong>\n{value} </dd>\n",
"substitutions": [
(r"&", r"&#8210;"),
(r"<p>", r"<p>\n\n"),
(r"\u2018([^\u2019]*)\u2019", r"<q>\1</q>"),
Expand All @@ -154,7 +154,7 @@ class OntoDoc:
(r"\u226B", r"&x226B;"),
(r'"Y$', r""), # strange noice added by owlready2
],
)
}

def __init__(self, onto, style="markdown"):
if isinstance(style, str):
Expand Down Expand Up @@ -243,15 +243,15 @@ def itemdoc(
substitutions = self.style.get("substitutions", [])

# Logical "sorting" of annotations
order = dict(
definition="00",
axiom="01",
theorem="02",
elucidation="03",
domain="04",
range="05",
example="06",
)
order = {
"definition": "00",
"axiom": "01",
"theorem": "02",
"elucidation": "03",
"domain": "04",
"range": "05",
"example": "06",
}

doc = []

Expand Down Expand Up @@ -409,7 +409,6 @@ def itemdoc(
key="Individuals", value=value, ontology=onto
)
)

return "\n".join(doc)

def itemsdoc(self, items, header_level=3):
Expand Down
9 changes: 5 additions & 4 deletions ontopy/ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,7 @@ def __contains__(self, other):
self.get_by_label(other)
except NoSuchLabelError:
return False
else:
return True
return True

def __objclass__(self):
# Play nice with inspect...
Expand Down Expand Up @@ -782,7 +781,7 @@ def save(
fmt = revmap.get(format, format)
filename = f"{self.name}.{fmt}"
else:
TypeError("`filename` and `format` cannot both be None.")
raise TypeError("`filename` and `format` cannot both be None.")
filename = os.path.join(dir, filename)
dir = Path(filename).resolve().parent

Expand Down Expand Up @@ -1465,7 +1464,9 @@ def closest_common_ancestor(*classes):
return cur
if len(mro) == 0:
mros.remove(mro)
raise Exception("A closest common ancestor should always exist !")
raise EMMOntoPyException(
"A closest common ancestor should always exist !"
)

def get_ancestors(self, classes, include="all", strict=True):
"""Return ancestors of all classes in `classes`.
Expand Down
5 changes: 4 additions & 1 deletion ontopy/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import owlready2
from owlready2 import ThingClass, PropertyClass, Thing, Restriction, Namespace
from owlready2 import Metadata
from ontopy.utils import EMMOntoPyException


def render_func(entity):
Expand Down Expand Up @@ -60,7 +61,9 @@ def get_parents(self, strict=False):
for cls in self.is_a
if isinstance(cls, owlready2.ObjectPropertyClass)
}
raise Exception("self has no parents - this should not be possible!")
raise EMMOntoPyException(
"self has no parents - this should not be possible!"
)


def _dir(self):
Expand Down

0 comments on commit f88f721

Please sign in to comment.