Skip to content

Commit

Permalink
Move validation to after propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
neNasko1 committed Nov 28, 2024
1 parent 63be89b commit 0d5e2c8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/spox/_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class Node(ABC):

out_variadic: Optional[int]
_traceback: Union[list[str], None]
_validate: bool

def __init__(
self,
Expand Down Expand Up @@ -130,13 +131,12 @@ def __init__(
else:
self.outputs = outputs

# Store validate for when the values are actually propagated
self._validate = validate

# Optionally store debug information about where this node was created
self._traceback = traceback.format_stack() if STORE_TRACEBACK else None

# Performs type checking using known flags (like type_members)
# and warns if type inference failed (some types are None).
if validate:
self.validate_types()
self.post_init(**kwargs)

@property
Expand Down Expand Up @@ -249,6 +249,12 @@ def get_output_vars(
input_prop_values = {}
# After typing everything, try to get values for outputs
self.inference(infer_types=infer_types, input_prop_values=input_prop_values)

# Performs type checking using known flags (like type_members)
# and warns if type inference failed (some types are None).
if self._validate:
self.validate_types()

out_values = self.propagate_values(input_prop_values)
return self.outputs._propagate_vars(out_values)

Expand Down

0 comments on commit 0d5e2c8

Please sign in to comment.