Conversation
There was a problem hiding this comment.
Pull request overview
Refactors netlist path shortening so it’s computed during KiCad netlist generation (instead of during the design crawl), and updates the shortening algorithm to be robust to nested pseudoblocks while removing the deprecated Pathname refdes mode.
Changes:
- Replace precomputed
NetBlock.path/NetBlock.class_pathwithNetBlock.path_classes(full-path, index-aligned) and introducePathShortenerto compute shortened paths at netlist emit time. - Remove
RefdesMode.Pathnamesupport and adjust KiCad netlist generation to always reference components byrefdes. - Update unit tests’ expected
NetBlockshapes and hierarchy class-path expectations.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| edg/electronics_model/NetlistGenerator.py | Removes crawl-time short-path calculation; adds PathShortener; changes NetBlock schema to carry full-path classes. |
| edg/electronics_model/footprint.py | Uses PathShortener during KiCad netlist generation; removes Pathname mode and short-path fields usage. |
| edg/electronics_model/NetlistBackend.py | Removes backend argument mapping for the deleted pathName refdes mode. |
| edg/electronics_model/test_netlist.py | Updates test helper constructor and expectations for full-path-aligned class lists. |
| edg/electronics_model/test_netlist_wrapper.py | Updates wrapper netlist expectations to match new NetBlock structure. |
| edg/electronics_model/test_multipack_netlist.py | Updates multipack netlist expectations for full-path class lists. |
| edg/electronics_model/test_bundle_netlist.py | Updates bundle netlist expectations to match new NetBlock structure. |
| edg/electronics_model/test_partplacer.py | Updates test fixtures to new NetBlock field name (path_classes). |
| edg/abstract_parts/test_kicad_import_netlist.py | Updates KiCad import netlist expectations to match new NetBlock structure. |
Comments suppressed due to low confidence (1)
edg/electronics_model/footprint.py:92
- The
block_expdocstring says it takes a dictionary of block names, but the function signature now takes aList[NetBlock]plus aPathShortener. Update the docstring to reflect the current inputs to avoid misleading future maintenance.
def block_exp(blocks: List[NetBlock], shortener: PathShortener, refdes_mode: RefdesMode) -> str:
"""Given a dictionary of block_names (strings) as keys and Blocks (namedtuples) as corresponding values
Example:
(components
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
edg/electronics_model/footprint.py
Outdated
Comment on lines
146
to
168
| @@ -170,7 +163,7 @@ def net_exp(nets: List[Net], blocks: List[NetBlock], refdes_mode: RefdesMode) -> | |||
| for i, net in enumerate(nets): | |||
| result += "\n" + gen_net_header(i + 1, net.name) | |||
| for pin in net.pins: | |||
| result += "\n " + gen_net_pin(block_name(block_dict[pin.block_path], refdes_mode), pin.pin_name) | |||
| result += "\n " + gen_net_pin(block_dict[pin.block_path].refdes, pin.pin_name) | |||
| result += ")" | |||
| return result + ")" | |||
| def shorten( | ||
| self, path: TransformUtil.Path, classes: List[edgir.LibraryPath] | ||
| ) -> Tuple[List[str], List[edgir.LibraryPath]]: | ||
| assert len(path.blocks) == len(classes) |
Comment on lines
21
to
31
| def NetBlock( | ||
| footprint: str, refdes: str, part: str, value: str, full_path: List[str], path: List[str], class_path: List[str] | ||
| footprint: str, refdes: str, part: str, value: str, full_path: List[str], class_path: List[str] | ||
| ) -> RawNetBlock: | ||
| return RawNetBlock( | ||
| footprint, | ||
| refdes, | ||
| part, | ||
| value, | ||
| TransformUtil.Path(tuple(full_path), (), (), ()), | ||
| path, | ||
| [edgir.libpath(cls) for cls in class_path], | ||
| ) |
Comment on lines
10
to
17
| u1 = NetBlock( | ||
| footprint="Package_QFP:LQFP-48-1EP_7x7mm_P0.5mm_EP3.6x3.6mm", | ||
| refdes="U1", | ||
| part="", | ||
| value="", | ||
| full_path=TransformUtil.Path.empty().append_block("U1"), | ||
| path=[], | ||
| class_path=[], | ||
| path_classes=[], | ||
| ) |
Comment on lines
46
to
77
| u1 = NetBlock( | ||
| footprint="Package_QFP:LQFP-48-1EP_7x7mm_P0.5mm_EP3.6x3.6mm", | ||
| refdes="U1", | ||
| part="", | ||
| value="", | ||
| full_path=TransformUtil.Path.empty().append_block("A").append_block("U1"), | ||
| path=[], | ||
| class_path=[], | ||
| path_classes=[], | ||
| ) | ||
| r1 = NetBlock( | ||
| footprint="Resistor_SMD:R_0603_1608Metric", | ||
| refdes="R1", | ||
| part="", | ||
| value="", | ||
| full_path=TransformUtil.Path.empty().append_block("A").append_block("R1"), | ||
| path=[], | ||
| class_path=[], | ||
| path_classes=[], | ||
| ) | ||
| r2 = NetBlock( | ||
| footprint="Resistor_SMD:R_0603_1608Metric", | ||
| refdes="R2", | ||
| part="", | ||
| value="", | ||
| full_path=TransformUtil.Path.empty().append_block("A").append_block("R2"), | ||
| path=[], | ||
| class_path=[], | ||
| path_classes=[], | ||
| ) | ||
| r3 = NetBlock( | ||
| footprint="Resistor_SMD:R_0603_1608Metric", | ||
| refdes="R3", | ||
| part="", | ||
| value="", | ||
| full_path=TransformUtil.Path.empty().append_block("B").append_block("R3"), | ||
| path=[], | ||
| class_path=[], | ||
| path_classes=[], | ||
| ) |
Comment on lines
129
to
144
| r1 = NetBlock( | ||
| footprint="Resistor_SMD:R_0603_1608Metric", | ||
| refdes="R1", | ||
| part="", | ||
| value="", | ||
| full_path=TransformUtil.Path.empty().append_block("R1"), | ||
| path=[], | ||
| class_path=[], | ||
| path_classes=[], | ||
| ) | ||
| r2 = NetBlock( | ||
| footprint="Resistor_SMD:R_0603_1608Metric", | ||
| refdes="R2", | ||
| part="", | ||
| value="", | ||
| full_path=TransformUtil.Path.empty().append_block("R2"), | ||
| path=[], | ||
| class_path=[], | ||
| path_classes=[], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Instead of calculating the short path in the design crawl, this calculates it during netlist generation.
Also changes the algorithm to eliminate path components with no footprint-containing siblings. Previously, it approximated this, but was brittle to sub-blocks even if they contained no leaf footprints. This is needed for compositional passive, where there are going to be nested pseudoblocks.
Removes Pathname mode for netlisting. It's effectively superseded by PathnameAsValue mode.
Reference netlists are unchanged.