From 642f3405175bdabd3177b3bcc711c24504e26ba5 Mon Sep 17 00:00:00 2001 From: mouffok Date: Thu, 26 Oct 2023 16:40:26 +0200 Subject: [PATCH] fix pycodestyle --- kgforge/core/archetypes/resolver.py | 2 +- kgforge/core/commons/sparql_query_builder.py | 6 +++--- kgforge/specializations/models/demo_model.py | 2 +- kgforge/specializations/models/rdf/pyshacl_shape_wrapper.py | 2 +- .../models/rdf/rdf_model_service_from_store.py | 1 - 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/kgforge/core/archetypes/resolver.py b/kgforge/core/archetypes/resolver.py index c37b81d9..5dc6d2b7 100644 --- a/kgforge/core/archetypes/resolver.py +++ b/kgforge/core/archetypes/resolver.py @@ -229,7 +229,7 @@ def _build_resolving_query(text, query_template, deprecated_property, filters, s target_query_statements, target_query_filters = query_builder.build( None, None, resolving_context, configured_target_filters ) - + target_query_statements = ";\n ".join(target_query_statements) target_query_filters = "\n ".join(target_query_filters) first_filters = f"{first_filters} ; \n {target_query_statements}" diff --git a/kgforge/core/commons/sparql_query_builder.py b/kgforge/core/commons/sparql_query_builder.py index c41a4ac0..45b37865 100644 --- a/kgforge/core/commons/sparql_query_builder.py +++ b/kgforge/core/commons/sparql_query_builder.py @@ -40,6 +40,8 @@ class CategoryDataType(Enum): LITERAL = "literal" # FIXME: need to find a comprehensive way (different than list) to get all SPARQL reserved clauses + + SPARQL_CLAUSES = [ "where", "filter", @@ -116,7 +118,6 @@ class CategoryDataType(Enum): class SPARQLQueryBuilder(QueryBuilder): - @staticmethod def build( schema: Dict, @@ -287,8 +288,7 @@ def replace(match: Match) -> str: else: v = ( ctx.get(m4, ":" + m4 if context.has_vocab() else None) - if str(m4).lower() not in SPARQL_CLAUSES - and not str(m4).startswith("https") + if str(m4).lower() not in SPARQL_CLAUSES and not str(m4).startswith("https") else m4 ) if v is None: diff --git a/kgforge/specializations/models/demo_model.py b/kgforge/specializations/models/demo_model.py index ac03d518..cd651c61 100644 --- a/kgforge/specializations/models/demo_model.py +++ b/kgforge/specializations/models/demo_model.py @@ -75,7 +75,7 @@ def mapping(self, entity: str, source: str, type: Type[Mapping]) -> Mapping: filename = f"{entity}.hjson" filepath = Path(self.source, "mappings", source, type.__name__, filename) if filepath.is_file(): - return type.load(filepath) # TODO should be str + return type.load(filepath) # TODO should be str raise ValueError("unrecognized entity type or source") diff --git a/kgforge/specializations/models/rdf/pyshacl_shape_wrapper.py b/kgforge/specializations/models/rdf/pyshacl_shape_wrapper.py index d1a64b10..bc6af033 100644 --- a/kgforge/specializations/models/rdf/pyshacl_shape_wrapper.py +++ b/kgforge/specializations/models/rdf/pyshacl_shape_wrapper.py @@ -85,4 +85,4 @@ def lookup_shape_from_node(self, node: URIRef) -> Optional[ShapeWrapper]: # if not hasattr(shape_wrapper, "traverse"): # shape_wrapper.traverse = types.MethodType(traverse, shape_wrapper) # return shape_wrapper - return None \ No newline at end of file + return None diff --git a/kgforge/specializations/models/rdf/rdf_model_service_from_store.py b/kgforge/specializations/models/rdf/rdf_model_service_from_store.py index 36480e17..8a65b0c2 100644 --- a/kgforge/specializations/models/rdf/rdf_model_service_from_store.py +++ b/kgforge/specializations/models/rdf/rdf_model_service_from_store.py @@ -174,4 +174,3 @@ def _load_shape_and_reload_shapes_graph(self, resource_id: str): self._load_shape(resource_id) # reloads the shapes graph self._shapes_graph = ShapesGraphWrapper(self._graph) -