Skip to content

Conversation

@skarndev
Copy link
Contributor

@skarndev skarndev commented Jan 17, 2026

Added a generalized algorithm to handle builtins exposed via the types module, but reporting builtins at introspection.

Why

Importing types, via pybind11 such as py::module::import("types").attr("MappingProxyType") currently yields an unresolved name "mappingproxy" in the generated .pyi stubs.
The reason for this is that the MappingProxyType.__qualname__ at runtime is "mappingproxy" and __module__ is "builtins". However, the actual builtins module does not expose this as an importable attribute.

There are a number of other "hidden" builtins that follow this pattern. They all seem to come from the types module. I also left room for overriding this behavior, as was done before for "function" and "builtin_function_or_method".

Added a generalized algorithm to handle builtins exposed via the 
`types` module, but reporting `builtins` at introspection.
@ax3l ax3l requested review from ax3l and virtuald January 22, 2026 07:44
return QualifiedName((Identifier("None"),))

hidden_builtin = self._hidden_builtins.get(typename)
if hidden_builtin is not None:
Copy link
Contributor

@ax3l ax3l Jan 22, 2026

Choose a reason for hiding this comment

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

Do you want to add a few inline comments to make the logic easier to read (e.g., what you wrote in the PR description)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, will do.

@ax3l ax3l added the bug Something isn't working label Jan 22, 2026
@skarndev
Copy link
Contributor Author

Test cases for this also need to be added.

@skarndev skarndev marked this pull request as draft January 22, 2026 18:48
@ax3l ax3l mentioned this pull request Jan 23, 2026
14 tasks
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.

2 participants