Skip to content

Remove function comparison #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions src/validate_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@

class BreakingChangeType(Enum):
RETURN_TYPES_CHANGED = "Return types changed"
INPUT_REMOVED = "Required input removed"
INPUT_TYPE_CHANGED = "Input type changed"
NODE_REMOVED = "Node removed"
FUNCTION_CHANGED = "Entry point function changed"

@dataclass
class BreakingChange:
Expand Down Expand Up @@ -104,24 +101,6 @@ def compare_return_types(node_name: str, base_class: Type, pr_class: Type) -> li

return changes

def compare_function(node_name: str, base_class: Type, pr_class: Type) -> list[BreakingChange]:
"""Compare FUNCTION attribute between base and PR versions of a node."""
changes = []

base_function = getattr(base_class, "FUNCTION", None)
pr_function = getattr(pr_class, "FUNCTION", None)

if base_function != pr_function:
changes.append(BreakingChange(
node_name=node_name,
change_type=BreakingChangeType.FUNCTION_CHANGED,
details="Entry point function changed",
base_value=base_function,
pr_value=pr_function
))

return changes

def compare_nodes(base_nodes: Dict[str, Type], pr_nodes: Dict[str, Type]) -> list[BreakingChange]:
"""Compare two versions of nodes for breaking changes."""
changes = []
Expand All @@ -140,7 +119,6 @@ def compare_nodes(base_nodes: Dict[str, Type], pr_nodes: Dict[str, Type]) -> lis
pr_class = pr_nodes[node_name]

changes.extend(compare_return_types(node_name, base_class, pr_class))
changes.extend(compare_function(node_name, base_class, pr_class))

return changes

Expand Down
40 changes: 0 additions & 40 deletions tests/test_validate_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,43 +59,3 @@ def test_compare_return_types_missing():
assert changes[0].base_value == ("STRING", "INT", "FLOAT")
assert changes[0].pr_value == tuple()


def test_compare_function():
from src.validate_nodes import compare_function, BreakingChangeType

class BaseNode:
FUNCTION = "process"

class PRNode:
FUNCTION = "process"

class ChangedNode:
FUNCTION = "different_process"

class NoFunctionNode:
pass

# Test 1: No changes
changes = compare_function("TestNode", BaseNode, PRNode)
assert len(changes) == 0

# Test 2: Function changed
changes = compare_function("TestNode", BaseNode, ChangedNode)
assert len(changes) == 1
assert changes[0].change_type == BreakingChangeType.FUNCTION_CHANGED
assert changes[0].base_value == "process"
assert changes[0].pr_value == "different_process"

# Test 3: Function removed
changes = compare_function("TestNode", BaseNode, NoFunctionNode)
assert len(changes) == 1
assert changes[0].change_type == BreakingChangeType.FUNCTION_CHANGED
assert changes[0].base_value == "process"
assert changes[0].pr_value is None

# Test 4: Function added (not a breaking change if base had none)
changes = compare_function("TestNode", NoFunctionNode, BaseNode)
assert len(changes) == 1
assert changes[0].change_type == BreakingChangeType.FUNCTION_CHANGED
assert changes[0].base_value is None
assert changes[0].pr_value == "process"
Loading