Skip to content

Commit

Permalink
fix mypy arg type
Browse files Browse the repository at this point in the history
  • Loading branch information
msaipraneeth committed Mar 14, 2024
1 parent 8c59333 commit 58744a3
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions cmem_plugin_pyshacl/plugin_pyshacl.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
Namespace,
URIRef,
)
from rdflib.term import Node
from strtobool import strtobool
from validators import url as validator_url

Expand Down Expand Up @@ -393,8 +394,8 @@ def add_labels_val(
subject=validation_result_uri, predicate=SH.resultPath
)
result_path_string = f"{result_path}: " if result_path else ""
label = f"SHACL: {result_path_string}{message}"
validation_graph.add((validation_result_uri, RDFS.label, Literal(label)))
label = Literal(f"SHACL: {result_path_string}{message}")
validation_graph.add((validation_result_uri, RDFS.label, label))
if self.include_graphs_labels:
focus_node = validation_graph.value(
subject=validation_result_uri, predicate=SH.focusNode
Expand All @@ -403,18 +404,18 @@ def add_labels_val(
focus_nodes.append(focus_node)
label = get_label(data_graph, focus_node)
if label and focus_node:
validation_graph.add((focus_node, RDFS.label, label))
validation_graph.add((focus_node, RDFS.label, label)) # type: ignore[arg-type]
value = validation_graph.value(subject=validation_result_uri, predicate=SH.value)
if value and isinstance(value, URIRef | BNode):
label = get_label(data_graph, value)
if label:
validation_graph.add((value, RDFS.label, label))
validation_graph.add((value, RDFS.label, label)) # type: ignore[arg-type]
source_shape = validation_graph.value(
subject=validation_result_uri, predicate=SH.sourceShape
)
label = get_label(shacl_graph, source_shape)
if label:
validation_graph.add((source_shape, RDFS.label, label))
validation_graph.add((source_shape, RDFS.label, label)) # type: ignore[arg-type]
return validation_graph, focus_nodes

def add_shui_conforms_val(
Expand Down Expand Up @@ -456,7 +457,7 @@ def post_graph(self, validation_graph: Graph) -> None:
self.log.info("Error posting SHACL validation graph: " f"status code {res.status_code}")

def check_object( # noqa: C901 PLR0912 PLR0913
self, graph: Graph, subj: URIRef, pred: URIRef, data_graph: Graph, shacl_graph: Graph
self, graph: Graph, subj: Node, pred: URIRef, data_graph: Graph, shacl_graph: Graph
) -> str:
"""Format RDF objects for entities output"""
if pred in (SH.sourceShape, SH.conforms):
Expand Down Expand Up @@ -668,7 +669,7 @@ def execute( # noqa: C901 PLR0912
validation_graph = validation_graph.skolemize(basepath=self.validation_graph_uri)
if self.add_labels or self.add_shui_conforms:
validation_graph_uris = validation_graph.subjects(RDF.type, SH.ValidationResult)
focus_nodes = None
focus_nodes = []
if self.add_labels:
validation_graph, focus_nodes = self.add_labels_val(
validation_graph, data_graph, shacl_graph, validation_graph_uris
Expand Down

0 comments on commit 58744a3

Please sign in to comment.