Skip to content

Add optional concrete fallback definition after overload stubs#313

Closed
dyollb wants to merge 2 commits into
pybind:mainfrom
dyollb:print_overload_fallback
Closed

Add optional concrete fallback definition after overload stubs#313
dyollb wants to merge 2 commits into
pybind:mainfrom
dyollb:print_overload_fallback

Conversation

@dyollb

@dyollb dyollb commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Add optional concrete fallback definition after overload stubs

Why:

Some tools (for example Griffe during re-export resolution) cannot reliably resolve symbols defined only as overload stubs. Emitting a concrete non-overload signature after the overload set preserves typing quality while ensuring symbol resolution works.

What:

  1. Added a new CLI option: --print-overload-fallback.
  2. Updated Printer emission flow to append one concrete fallback definition after overloaded function/method groups when the option is enabled.
  3. Kept existing @typing.overload signatures unchanged for typing precision.
  4. Refactored fallback processing logic to reduce duplication between function and method paths.
  5. Added/updated tests to verify:
  6. fallback is emitted when enabled,
  7. fallback is not emitted when disabled.

@dyollb

dyollb commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

maybe this is a bug/issue in griffe and does not need a solution in pybind stubgen
mkdocstrings/griffe#417

@skarndev

Copy link
Copy Markdown
Contributor

This does not seem to be required for using stubs for typechecking purposes. I don't seem to have an issue when running .pyi through e.g. mypy, even though more recent typechekers like zuban, ty and pyrefly need separate testing.
Maybe that should be handled on Griffe's side instead?

@dyollb

dyollb commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

I agree. It is even marked as bug in griffe. Closing

@dyollb dyollb closed this Jun 30, 2026
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.

2 participants