Skip to content

Add draft stub generation and Action typing - #507

Draft
james-d-mitchell wants to merge 1 commit into
mainfrom
codex/stub-stdout
Draft

james-d-mitchell wants to merge 1 commit into
mainfrom
codex/stub-stdout

Conversation

@james-d-mitchell

Copy link
Copy Markdown
Member

Dynamic wrapper methods and native bindings lose useful type information during ordinary stub generation. This adds a reusable generator that combines pybind11-stubgen discovery with source annotations, generic bases, and documented signatures.

  • Require an explicit module and print a single stub to stdout, keeping diagnostics on stderr. Files are written only with --output-dir; replacing existing files requires --force.
  • Default extension generation to publicly exported native classes and their typing dependencies. --no-public-only requests the full extension, and --strict stops on backend diagnostics.
  • Add sample Action and BMat8 helper-module stubs, make Action generic in its element and point types, and correct the copy_cxx_mem_fns class annotation.
  • Document usage and cover generation, public-class selection, output handling, and mypy consumer checks.

Generated stubs remain drafts: some native signatures still need manual correction. The mypy tests cover Action and an isolated BMat8 section, not the complete native stub. This does not add a py.typed marker.

Validation:

  • uv run --offline --no-sync --with pybind11-stubgen==2.5.5 --with mypy==2.3.1 pytest tests/test_generate_stubs.py tests/test_action.py tests/test_bmat8.py -k 'not test_action_transf': 58 passed, 1 deselected. The excluded test enumerates a large transformation action.
  • Both pre-commit hook stages passed on all changed files; explicit Ruff checks and formatting passed for the generator as well.
  • Confirmed tests use the package and built extension from this checkout. No C++ rebuild was needed; documentation builds and the full test suite were not run for this Python typing/tooling change.

AI disclosure: OpenAI Codex helped prepare the implementation, tests, documentation, commit message, and this PR description, and ran validation. The commit includes Assisted-by: Codex <codex@openai.com> and Co-authored-by: Codex <codex@openai.com> trailers.

Generate stubs from runtime bindings, source annotations, and documented
signatures. Require an explicit module, print to stdout by default, and
select public native classes plus typing dependencies for extension targets.

Add sample Action and BMat8 helper stubs, bind Action's element and point
types to the class, and accept CxxWrapper subclasses in copy_cxx_mem_fns.

AI disclosure: OpenAI Codex helped prepare the implementation, tests,
documentation, commit message, and PR description, and ran validation.

Assisted-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
@james-d-mitchell

Copy link
Copy Markdown
Member Author

This is a partial attempt (or start of an attempt) to resolve #476

This branch has not been deployed

No deployments
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