Skip to content

Fix nested qualname simple#280

Merged
ax3l merged 3 commits into
pybind:masterfrom
ax3l:fix-nested-qualname-simple
Jan 22, 2026
Merged

Fix nested qualname simple#280
ax3l merged 3 commits into
pybind:masterfrom
ax3l:fix-nested-qualname-simple

Conversation

@ax3l

@ax3l ax3l commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

Fixes #266
Fixes #272

Takes the tests from #272 and the simple fix from the large PR in #263.
Credits to @gentlegiantJGC and @sarlinpe 🙏

gentlegiantJGC and others added 2 commits January 21, 2026 23:35
* Remove current module from nested types

Types like union types have nested types in them.
The current implementation only removes the current module name from the root type name.
This modifies that behaviour so that it expands nested types recursively.

* Add tests

* Reorder variant types

pybind11 requires that arguments are default constructable but Foo is not

* Reorder types in union

* Add nested types to all

* Add missing stubs
@ax3l

ax3l commented Jan 22, 2026

Copy link
Copy Markdown
Contributor Author

@skarndev I let you do a final review & merge on this one.

@ax3l ax3l merged commit c3fcfa0 into pybind:master Jan 22, 2026
19 checks passed
@ax3l ax3l deleted the fix-nested-qualname-simple branch January 22, 2026 15:47
@markuspi

Copy link
Copy Markdown
Contributor

@ax3l Thanks for this fix. Do you guys have an estimation when the next pypi release will be published that includes this commit?

hugary1995 added a commit to applied-material-modeling/neml2 that referenced this pull request Jun 11, 2026
Replaces the hand-written ``_aoti.pyi`` with a v2-style ``neml2-stub``
console script that runs ``pybind11-stubgen`` against every discovered
extension in the installed package. Walks ``neml2.*`` via
``pkgutil.walk_packages`` + filters on ``importlib.machinery.EXTENSION_SUFFIXES``
so new pybind11 modules (when we add them) are picked up automatically.

* Stub output dir is derived per-module from the spec's ``.so``
  location, not ``neml2.__path__[0]``. Editable installs carry both
  the site-packages shim and the source tree in ``__path__``, and the
  shim's parent is site-packages -- writing there strands the stub
  next to the wrong (incomplete) copy of the package.
* CI typecheck job grows a ``neml2-stub`` step between ``pip install``
  and ``pyright``.
* scripts/repair_wheel.py installs the freshly-built wheel, runs
  ``neml2-stub``, then unpacks the wheel + injects every ``.pyi``
  preserving its relative path under ``neml2/`` + repacks. Mirrors
  v2's repair flow so published wheels ship the stubs.
* cibuildwheel ``before-build`` grows ``pybind11-stubgen>=2.5.5``.
* ``.gitignore`` keeps ``*.pyi`` ignored; the previous hand-written
  carve-out is gone (stubs are pure build output now).

Worked around pybind/pybind11-stubgen#279 by
taking ``meta_path`` as ``std::string`` in the pybind binding (stub
annotation becomes ``str`` instead of ``os.PathLike``, sidestepping the
missing ``import os``). Drop the ``pybind11/stl/filesystem.h`` include;
the lambda converts to ``std::filesystem::path`` for the C++ ctor. Drop
the lambda + restore ``py::init<const std::filesystem::path &>()`` once
pybind/pybind11-stubgen#280 lands in a release.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

pybind11 filesystem: import os is missing in files with os.PathLike in stubs

6 participants