Add exclude section for genpackage - #124
Merged
Merged
Conversation
…sses Some wrapped classes (e.g. abstract bases) must stay in the compiled extension because concrete subclasses declare them as bases and C++ APIs traffic in them, but are not meant to be named or instantiated from Python. In the shared-module-split layout these showed up as "wrapped but not assigned to a subpackage" warnings, indistinguishable from an accidental omission. Add an optional `exclude:` list to the split layout: an excluded name is no longer warned about for being unplaced. genpackage still warns if an excluded name is also assigned to a subpackage (it would be exposed after all) or if an exclude entry no longer matches any wrapped class, enum or free function (e.g. after a rename). A module-per-subpackage layout exposes each module wholesale via `import *`, so `exclude` cannot hold individual names back there and is warned as ignored. Document the option in python-packages.md and add tests for each warning. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
In _BoundTemplateMethod, store the owning class alongside the instance and resolve the mangled-binding target lazily in __getitem__, instead of precomputing it in __init__; this keeps the "instance vs class access" logic next to its single use site. Add type annotations across the module's helpers (TemplateClass, TemplateMethod, _BoundTemplateMethod and _normalize_key), replacing the previous partial annotations. The return types document the descriptor protocol (what __get__, __class_getitem__ and __getitem__ hand back); deliberately-any subscript keys are annotated `object`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #124 +/- ##
========================================
Coverage 99.75% 99.75%
========================================
Files 31 31
Lines 2469 2475 +6
Branches 532 534 +2
========================================
+ Hits 2463 2469 +6
Misses 5 5
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds exclude support for intentionally unexposed bindings in shared-module package generation.
Changes:
- Suppresses unassigned warnings for excluded names and validates conflicting/stale entries.
- Adds tests and documentation for exclusion behavior.
- Adds type annotations to example syntax helpers.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
cppwg/genpackage.py |
Implements exclusion handling and diagnostics. |
tests/test_genpackage.py |
Tests exclusion behavior. |
doc/python-packages.md |
Documents the new layout option. |
examples/shapes/src/py/pyshapes/_syntax.py |
Types template syntax helpers. |
examples/cells/src/py/pycells/_syntax.py |
Types template syntax helpers. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The "in the exclude list but also assigned to a subpackage, so it is exposed" guard fired on any name in both lists, including a stale name absent from the model. Such a name is never imported (it already draws "not found in model" and the stale-entry warning), so claiming it is exposed was misleading. Intersect the guard with the known wrapped set so it fires only for names that are genuinely exposed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Closes #102