Skip to content

Commit f3c0880

Browse files
author
linkmluser
committed
partial linting; added video to docs
1 parent 82780a5 commit f3c0880

4 files changed

Lines changed: 27 additions & 14 deletions

File tree

.coverage

0 Bytes
Binary file not shown.

docs/index.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,15 @@ You can either install directly from this link:
4343

4444
You can ask to create an ontology, and add axioms to an ontology:
4545

46-
47-
46+
<iframe
47+
width="500"
48+
height="560"
49+
src="https://www.youtube.com/embed/sAXs3djX854"
50+
title="YouTube video player"
51+
frameborder="0"
52+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
53+
allowfullscreen>
54+
</iframe>
4855

4956

5057
## How this works

src/owl_mcp/owl_api.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ def find_axioms(
255255
try:
256256
regex_pattern = re.compile(pattern)
257257
except re.error as e:
258-
raise re.error(f"Invalid regex pattern '{pattern}': {e}") from e
258+
msg = f"Invalid regex pattern '{pattern}': {e}"
259+
raise re.error(msg) from e
259260

260261
for axiom in axioms:
261262
if axiom_type and not axiom.startswith(axiom_type + "("):
@@ -289,7 +290,7 @@ def find_axioms(
289290
break
290291

291292
if prefix_start < colon_idx: # We have a potential prefix
292-
prefix = axiom_str[prefix_start:colon_idx]
293+
_ = axiom_str[prefix_start:colon_idx] # prefix var not used
293294

294295
# Find the end of the IRI
295296
end_idx = len(axiom_str)
@@ -366,7 +367,7 @@ def get_all_axiom_strings(
366367
break
367368

368369
if prefix_start < colon_idx: # We have a potential prefix
369-
prefix = axiom_str[prefix_start:colon_idx]
370+
_ = axiom_str[prefix_start:colon_idx] # prefix var not used
370371

371372
# Find the end of the IRI
372373
end_idx = len(axiom_str)
@@ -549,7 +550,7 @@ def get_labels_for_iri(self, iri: str, annotation_property: Optional[str] = None
549550
label_property = annotation_property or self.annotation_property
550551

551552
# Check if iri is a CURIE (e.g. "ex:Person") and handle appropriately
552-
if ":" in iri and not (iri.startswith("http://") or iri.startswith("https://")):
553+
if ":" in iri and not iri.startswith(("http://", "https://")):
553554
# This is a prefixed IRI, we need to get the full IRI
554555
prefix, local = iri.split(":", 1)
555556
# Get all prefixes to find the right one
@@ -566,12 +567,12 @@ def get_labels_for_iri(self, iri: str, annotation_property: Optional[str] = None
566567
# Get all annotations for this IRI with the specified property
567568
try:
568569
labels = self.ontology.get_annotations(full_iri, label_property)
569-
570-
# Return the string values of the annotations
571-
return labels if labels else []
572570
except Exception as e:
573571
logger.debug(f"Error getting labels for IRI {iri}: {e}")
574572
return []
573+
else:
574+
# Return the string values of the annotations
575+
return labels if labels else []
575576

576577
def stop(self) -> None:
577578
"""

tests/test_owl_api.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,25 +151,30 @@ def test_find_axioms_regex(owl_api):
151151

152152
# Test regex patterns
153153
# Find all ClassAssertion or SubClassOf axioms
154+
expected_class_or_subclass = 3
154155
found = owl_api.find_axioms(r"^(ClassAssertion|SubClassOf)")
155-
assert len(found) == 3
156+
assert len(found) == expected_class_or_subclass
156157

157158
# Find axioms containing either "John" or "Dog"
159+
expected_john_or_dog = 5 # All axioms contain either John or Dog
158160
found = owl_api.find_axioms(r":(John|Dog)")
159-
assert len(found) == 5 # All axioms contain either John or Dog
161+
assert len(found) == expected_john_or_dog
160162

161163
# Find axioms ending with specific patterns
164+
expected_ending_with_dog = 2 # ClassAssertion and ObjectPropertyAssertion
162165
found = owl_api.find_axioms(r"ex:Dog\)$")
163-
assert len(found) == 2 # ClassAssertion and ObjectPropertyAssertion
166+
assert len(found) == expected_ending_with_dog
164167

165168
# Find data property assertions with integer values
169+
expected_integer_property = 1
166170
found = owl_api.find_axioms(r'"\d+".*xsd:int')
167-
assert len(found) == 1
171+
assert len(found) == expected_integer_property
168172
assert axioms[4] in found
169173

170174
# Test case-insensitive matching
175+
expected_case_insensitive_person = 1
171176
found = owl_api.find_axioms(r"(?i)person")
172-
assert len(found) == 1
177+
assert len(found) == expected_case_insensitive_person
173178
assert axioms[0] in found
174179

175180

0 commit comments

Comments
 (0)