diff --git a/pyshacl/constraints/advanced/__init__.py b/pyshacl/constraints/advanced/__init__.py index 841bdc9..61e1539 100644 --- a/pyshacl/constraints/advanced/__init__.py +++ b/pyshacl/constraints/advanced/__init__.py @@ -7,7 +7,7 @@ import typing from typing import Dict, List -from rdflib import Literal +from rdflib import Literal, URIRef from pyshacl.constraints.constraint_component import ConstraintComponent from pyshacl.consts import SH, SH_message @@ -35,7 +35,7 @@ def __init__(self, shape: 'Shape'): ) @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[URIRef]: return [SH_expression] @classmethod diff --git a/pyshacl/constraints/constraint_component.py b/pyshacl/constraints/constraint_component.py index a70452e..cf02af9 100644 --- a/pyshacl/constraints/constraint_component.py +++ b/pyshacl/constraints/constraint_component.py @@ -68,7 +68,7 @@ def __init__(self, shape: 'Shape'): @classmethod @abc.abstractmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[URIRef]: raise NotImplementedError() # pragma: no cover @classmethod diff --git a/pyshacl/constraints/core/cardinality_constraints.py b/pyshacl/constraints/core/cardinality_constraints.py index 18b63d2..15ed91a 100644 --- a/pyshacl/constraints/core/cardinality_constraints.py +++ b/pyshacl/constraints/core/cardinality_constraints.py @@ -5,7 +5,7 @@ from typing import Dict, List, Optional from rdflib.namespace import XSD -from rdflib.term import Literal +from rdflib.term import Literal, URIRef from pyshacl.constraints.constraint_component import ConstraintComponent from pyshacl.consts import SH @@ -66,7 +66,7 @@ def __init__(self, shape, min_count_objects: Optional[List[RDFNode]] = None): ) @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[URIRef]: return [SH_minCount] @classmethod @@ -153,7 +153,7 @@ def __init__(self, shape, max_count_objects: Optional[List[RDFNode]] = None): ) @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[URIRef]: return [SH_maxCount] @classmethod diff --git a/pyshacl/constraints/core/logical_constraints.py b/pyshacl/constraints/core/logical_constraints.py index 7a27508..8f9a45b 100644 --- a/pyshacl/constraints/core/logical_constraints.py +++ b/pyshacl/constraints/core/logical_constraints.py @@ -48,7 +48,7 @@ def __init__(self, shape): self.not_list = not_list @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_not] @classmethod @@ -151,7 +151,7 @@ def __init__(self, shape): self.and_list = and_list @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_and] @classmethod @@ -247,7 +247,7 @@ def __init__(self, shape): self.or_list = or_list @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_or] @classmethod @@ -343,7 +343,7 @@ def __init__(self, shape): self.xone_nodes = xone_nodes @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_xone] @classmethod diff --git a/pyshacl/constraints/core/other_constraints.py b/pyshacl/constraints/core/other_constraints.py index 342cc3d..d57818d 100644 --- a/pyshacl/constraints/core/other_constraints.py +++ b/pyshacl/constraints/core/other_constraints.py @@ -54,7 +54,7 @@ def __init__(self, shape): self.in_vals = in_vals @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_in] @classmethod @@ -133,7 +133,7 @@ def __init__(self, shape): self.property_shapes = list(self.shape.objects(SH_property)) @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_closed, SH_ignoredProperties] @classmethod @@ -280,7 +280,7 @@ def __init__(self, shape): self.has_value_set = has_value_set @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_hasValue] @classmethod diff --git a/pyshacl/constraints/core/property_pair_constraints.py b/pyshacl/constraints/core/property_pair_constraints.py index 29c3e5a..a393432 100644 --- a/pyshacl/constraints/core/property_pair_constraints.py +++ b/pyshacl/constraints/core/property_pair_constraints.py @@ -46,7 +46,7 @@ def __init__(self, shape): self.property_compare_set = property_compare_set @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_equals] @classmethod @@ -173,7 +173,7 @@ def __init__(self, shape): self.property_compare_set = property_compare_set @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_disjoint] @classmethod @@ -298,7 +298,7 @@ def __init__(self, shape): self.property_compare_set = property_compare_set @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_lessThan] @classmethod @@ -449,7 +449,7 @@ def __init__(self, shape): self.property_compare_set = property_compare_set @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_lessThanOrEquals] @classmethod diff --git a/pyshacl/constraints/core/shape_based_constraints.py b/pyshacl/constraints/core/shape_based_constraints.py index 634e3bb..0388c0e 100644 --- a/pyshacl/constraints/core/shape_based_constraints.py +++ b/pyshacl/constraints/core/shape_based_constraints.py @@ -61,7 +61,7 @@ def __init__(self, shape): self.property_shapes = property_shapes @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_property] @classmethod @@ -155,7 +155,7 @@ def __init__(self, shape): self.node_shapes = node_shapes @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_node] @classmethod @@ -316,7 +316,7 @@ def __init__(self, shape): self.is_disjoint = is_disjoint @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_qualifiedValueShape, SH_qualifiedMinCount, SH_qualifiedValueShapesDisjoint, SH_qualifiedMaxCount] @classmethod diff --git a/pyshacl/constraints/core/string_based_constraints.py b/pyshacl/constraints/core/string_based_constraints.py index 5adf9a1..fedc612 100644 --- a/pyshacl/constraints/core/string_based_constraints.py +++ b/pyshacl/constraints/core/string_based_constraints.py @@ -43,7 +43,7 @@ def __init__(self, shape): self.allow_multi_rules = True @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: raise NotImplementedError() @classmethod @@ -132,7 +132,7 @@ def __init__(self, shape): self.string_rules = patterns_found @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_minLength] @classmethod @@ -212,7 +212,7 @@ def __init__(self, shape): self.string_rules = patterns_found @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_maxLength] @classmethod @@ -280,7 +280,7 @@ def __init__(self, shape): self.flags = None @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_pattern] @classmethod @@ -358,7 +358,7 @@ def __init__(self, shape): self.string_rules = language_ins_found @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_languageIn] @classmethod @@ -452,7 +452,7 @@ def __init__(self, shape): self.string_rules = {is_unique_lang.value} @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_uniqueLang] @classmethod diff --git a/pyshacl/constraints/core/value_constraints.py b/pyshacl/constraints/core/value_constraints.py index ce83eb7..fb2c066 100644 --- a/pyshacl/constraints/core/value_constraints.py +++ b/pyshacl/constraints/core/value_constraints.py @@ -8,7 +8,7 @@ import rdflib from rdflib.namespace import XSD -from rdflib.term import Literal +from rdflib.term import Literal, URIRef from pyshacl.constraints.constraint_component import ConstraintComponent from pyshacl.consts import ( @@ -70,7 +70,7 @@ def __init__(self, shape): self.class_rules = class_rules @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[URIRef]: return [SH_class] @classmethod @@ -184,7 +184,7 @@ def __init__(self, shape): self.datatype_rule = datatype_rules[0] @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[URIRef]: return [SH_datatype] @classmethod @@ -292,7 +292,7 @@ def __init__(self, shape): self.nodekind_rule = nodekind_rules[0] @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[URIRef]: return [SH_nodeKind] @classmethod diff --git a/pyshacl/constraints/core/value_range_constraints.py b/pyshacl/constraints/core/value_range_constraints.py index a4b285e..2ae2bac 100644 --- a/pyshacl/constraints/core/value_range_constraints.py +++ b/pyshacl/constraints/core/value_range_constraints.py @@ -45,7 +45,7 @@ def __init__(self, shape): self.min_vals = min_vals @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_minExclusive] @classmethod @@ -135,7 +135,7 @@ def __init__(self, shape): self.min_vals = min_vals @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_minInclusive] @classmethod @@ -225,7 +225,7 @@ def __init__(self, shape): self.max_vals = max_vals @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_maxExclusive] @classmethod @@ -315,7 +315,7 @@ def __init__(self, shape): self.max_vals = max_vals @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: return [SH_maxInclusive] @classmethod diff --git a/pyshacl/constraints/sparql/sparql_based_constraint_components.py b/pyshacl/constraints/sparql/sparql_based_constraint_components.py index 92c1ff9..0dcf14e 100644 --- a/pyshacl/constraints/sparql/sparql_based_constraint_components.py +++ b/pyshacl/constraints/sparql/sparql_based_constraint_components.py @@ -47,7 +47,7 @@ def __init__(self, constraint, shape: 'Shape', validator): self.query_helper.collect_prefixes() @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[rdflib.URIRef]: # TODO:coverage: this is never used for this constraint? return [] diff --git a/pyshacl/constraints/sparql/sparql_based_constraints.py b/pyshacl/constraints/sparql/sparql_based_constraints.py index 4fc8bf4..6605111 100644 --- a/pyshacl/constraints/sparql/sparql_based_constraints.py +++ b/pyshacl/constraints/sparql/sparql_based_constraints.py @@ -5,6 +5,7 @@ from typing import Dict, List import rdflib +from rdflib import URIRef from pyshacl.constraints.constraint_component import ConstraintComponent from pyshacl.consts import SH, SH_deactivated, SH_message, SH_select @@ -81,7 +82,7 @@ def __init__(self, shape): self.sparql_constraints = sparql_constraints @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[URIRef]: return [SH_sparql] @classmethod diff --git a/pyshacl/extras/js/constraint.py b/pyshacl/extras/js/constraint.py index 1b7b228..a2f076b 100644 --- a/pyshacl/extras/js/constraint.py +++ b/pyshacl/extras/js/constraint.py @@ -3,7 +3,7 @@ import typing from typing import Dict, List -from rdflib import Literal +from rdflib import Literal, URIRef from pyshacl.constraints import ConstraintComponent from pyshacl.consts import SH, SH_js, SH_message @@ -70,7 +70,7 @@ def __init__(self, shape: 'Shape'): self.js_impls = [JSConstraintImpl(shape.sg, j) for j in js_decls] @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[URIRef]: return [SH_js] @classmethod diff --git a/pyshacl/extras/js/constraint_component.py b/pyshacl/extras/js/constraint_component.py index defe46c..19572a9 100644 --- a/pyshacl/extras/js/constraint_component.py +++ b/pyshacl/extras/js/constraint_component.py @@ -3,7 +3,7 @@ import typing from typing import Any, Dict, List, Tuple, Union -from rdflib import Literal +from rdflib import Literal, URIRef from pyshacl.constraints import ConstraintComponent from pyshacl.constraints.constraint_component import CustomConstraintComponent @@ -65,7 +65,7 @@ def bind_params(self): self.param_bind_map = bind_map @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[URIRef]: # TODO:coverage: this is never used for this constraint? return [] diff --git a/pyshacl/extras/js/target.py b/pyshacl/extras/js/target.py index eaf04d9..87a8191 100644 --- a/pyshacl/extras/js/target.py +++ b/pyshacl/extras/js/target.py @@ -35,7 +35,7 @@ def __init__(self, target_type: 'JSTargetType', target_declaration, shape: 'Shap self.params_kv = params_kv # type: dict @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[URIRef]: return [] @classmethod diff --git a/pyshacl/target.py b/pyshacl/target.py index 2df6c36..bd4cf8f 100644 --- a/pyshacl/target.py +++ b/pyshacl/target.py @@ -2,6 +2,8 @@ from typing import List, Sequence, Type, Union from warnings import warn +from rdflib import URIRef + from .constraints import ConstraintComponent from .consts import SH, RDF_type, RDFS_subClassOf, SH_parameter, SH_select, SH_SPARQLTargetType from .errors import ConstraintLoadError, ShapeLoadError @@ -105,7 +107,7 @@ def __init__(self, target_type, target_declaration, shape, param_vals=None): self.param_vals = param_vals @classmethod - def constraint_parameters(cls): + def constraint_parameters(cls) -> List[URIRef]: return [] @classmethod