Skip to content

Detect duplicate cell names before writing layouts#997

Open
joamatab wants to merge 4 commits into
mainfrom
detect-duplicate-cell-names
Open

Detect duplicate cell names before writing layouts#997
joamatab wants to merge 4 commits into
mainfrom
detect-duplicate-cell-names

Conversation

@joamatab

Copy link
Copy Markdown
Collaborator

Summary

  • Add DuplicateCellNameError and a pre-write check (_check_duplicate_cell_names) that validates all cells in the write set have unique names before writing GDS/OASIS files
  • The error message details which names are duplicated, how many cells share each name, and suggests enabling kf.config.debug_names for earlier detection
  • Fix pre-existing ty type-checker false positive for os.sched_getaffinity on macOS

Test plan

  • Verify writing a layout with unique cell names still works normally
  • Verify writing a layout with duplicate cell names raises DuplicateCellNameError with a clear message
  • Run existing test suite to check for regressions

GDS/OASIS formats require unique cell names. Add a pre-write check
that raises DuplicateCellNameError with details about which names
collide, helping users diagnose the issue before it corrupts output.

Also suppress a ty type-checker false positive for os.sched_getaffinity
(platform-dependent attribute handled at runtime via AttributeError).
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 27.50000% with 58 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.93%. Comparing base (23989f8) to head (81def66).

Files with missing lines Patch % Lines
src/kfactory/kcell.py 26.53% 34 Missing and 2 partials ⚠️
src/kfactory/layout.py 33.33% 14 Missing and 2 partials ⚠️
src/kfactory/conf.py 0.00% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #997      +/-   ##
==========================================
- Coverage   71.06%   70.93%   -0.13%     
==========================================
  Files          72       72              
  Lines       14708    14762      +54     
  Branches     2852     2868      +16     
==========================================
+ Hits        10452    10472      +20     
- Misses       3371     3400      +29     
- Partials      885      890       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

joamatab added 3 commits June 26, 2026 09:32
Deduplicate the repetitive name-conflict branches in TKCell.name
setter into a single code path. Also add _check_duplicate_cell_names
to KCLayout.write() so the layout-level write path catches duplicates
the same way ProtoTKCell.write() does.
Replaces try/except AttributeError with a hasattr check so that ty
can narrow the type on both macOS (attribute absent) and Linux
(attribute present) without needing a platform-specific ignore comment.
@joamatab joamatab added the bug Something isn't working label Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant