Skip to content

Commit

Permalink
Fix mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleysommer committed Sep 11, 2020
1 parent ea997c2 commit abb57fa
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions pyshacl/constraints/sparql/sparql_based_constraint_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""
import typing

from typing import Dict, List, Tuple, Union
from typing import Any, Dict, List, Set, Tuple, Type, Union

import rdflib

Expand Down Expand Up @@ -117,7 +117,7 @@ def __new__(cls, shacl_graph: 'ShapesGraph', node, *args, **kwargs):
return found_in_cache
sg = shacl_graph.graph
type_vals = set(sg.objects(node, RDF_type))
validator_type = None
validator_type: Union[Type[SelectConstraintValidator], Type[AskConstraintValidator], None] = None
if len(type_vals) > 0:
if SH_SPARQLSelectValidator in type_vals:
validator_type = SelectConstraintValidator
Expand Down Expand Up @@ -332,10 +332,10 @@ def validate(self, focus, value_nodes, target_graph, query_helper=None, new_bind


class CustomConstraintComponentFactory(object):
__slots__ = set()
__slots__: Tuple = tuple()

def __new__(cls, shacl_graph: 'ShapesGraph', node):
self = list()
self: List[Any] = list()
self.append(shacl_graph)
self.append(node)
optional_params = []
Expand Down Expand Up @@ -406,7 +406,15 @@ def __new__(cls, shacl_graph: 'ShapesGraph', node):


class CustomConstraintComponent(object):
__slots__ = ('sg', 'node', 'parameters', 'validators', 'node_validators', 'property_validators')
__slots__: Tuple = ('sg', 'node', 'parameters', 'validators', 'node_validators', 'property_validators')

if typing.TYPE_CHECKING:
sg: ShapesGraph
node: Any
parameters: List[SHACLParameter]
validators: Set
node_validators: Set
property_validators: Set

def __new__(cls, shacl_graph: 'ShapesGraph', node, parameters, validators, node_validators, property_validators):
self = super(CustomConstraintComponent, cls).__new__(cls)
Expand All @@ -429,7 +437,7 @@ class SPARQLConstraintComponent(CustomConstraintComponent):
https://www.w3.org/TR/shacl/#sparql-constraint-components
"""

__slots__ = set()
__slots__: Tuple = tuple()

def __new__(cls, shacl_graph, node, parameters, validators, node_validators, property_validators):
return super(SPARQLConstraintComponent, cls).__new__(
Expand Down

0 comments on commit abb57fa

Please sign in to comment.