Skip to content

fix(connectivity): Use list instead of set for Net objects#187

Open
shanemmattner wants to merge 1 commit into
mainfrom
fix/connectivity-analyzer-unhashable-net
Open

fix(connectivity): Use list instead of set for Net objects#187
shanemmattner wants to merge 1 commit into
mainfrom
fix/connectivity-analyzer-unhashable-net

Conversation

@shanemmattner
Copy link
Copy Markdown
Contributor

Summary

  • Fix TypeError: unhashable type: 'Net' in ConnectivityAnalyzer._add_wire_to_net()
  • Change existing_nets from set() to list() since Net objects are mutable and should not be hashable

Problem

When analyzing schematics with multiple wires connecting to the same pins, the connectivity analyzer crashed:

existing_nets = set()
for pin in pins:
    if pin in self._pin_to_net:
        existing_nets.add(self._pin_to_net[pin])  # TypeError: unhashable type: 'Net'

Net is a mutable dataclass (has merge(), add_pin() methods) and correctly does not define __hash__. But the code tried to add Net objects to a Python set.

Solution

Use a list with membership check instead:

existing_nets = []
for pin in pins:
    if pin in self._pin_to_net:
        net = self._pin_to_net[pin]
        if net not in existing_nets:
            existing_nets.append(net)

Test plan

  • All 53 hierarchical connectivity tests pass
  • Tested on real Motor Driver schematic (101 nets, 113 components)
  • Existing ERC tests unaffected (were already failing before this change)

🤖 Generated with Claude Code

Net objects are mutable (they have merge() and add_pin() methods) and
should not be hashable. Changed existing_nets from set() to list() in
_add_wire_to_net() to fix TypeError: unhashable type: 'Net'.

The bug occurred when analyzing schematics with multiple wires
connecting to the same pins, causing the analyzer to try adding
Net objects to a set.

Fixes connectivity analysis for complex schematics like the Motor
Driver schematic (101 nets, 113 components).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant