Skip to content

Add exclude section for genpackage - #124

Merged
kwabenantim merged 3 commits into
developfrom
102-genpackage-exclude
Aug 13, 2026
Merged

Add exclude section for genpackage#124
kwabenantim merged 3 commits into
developfrom
102-genpackage-exclude

Conversation

@kwabenantim

Copy link
Copy Markdown
Member

Closes #102

kwabenantim and others added 2 commits August 13, 2026 15:58
…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>
@kwabenantim
kwabenantim requested a balanced review from Copilot August 13, 2026 15:15
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.75%. Comparing base (8694917) to head (cfe48c5).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           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           
Flag Coverage Δ
cells 71.08% <0.00%> (-0.18%) ⬇️
shapes 71.11% <0.00%> (-0.18%) ⬇️
unit 93.16% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cppwg/genpackage.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread cppwg/genpackage.py Outdated
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@kwabenantim
kwabenantim marked this pull request as ready for review August 13, 2026 15:53
@kwabenantim
kwabenantim merged commit f570136 into develop Aug 13, 2026
18 checks passed
@kwabenantim
kwabenantim deleted the 102-genpackage-exclude branch August 13, 2026 15:54
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.

Generate the Python package from the wrapper config

2 participants