Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix module type hint #5469

Merged
merged 5 commits into from
Dec 31, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,7 @@ PYBIND11_NAMESPACE_BEGIN(detail)

template <>
struct handle_type_name<module_> {
static constexpr auto name = const_name("module");
static constexpr auto name = const_name("types.ModuleType");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please add a test? I think it's really simple:

Add in tests/test_modules.py:

def test_module_handle_type_name():
    assert m.def_submodule.__doc__ == "TODO"

or possibly

def test_module_handle_type_name(doc):
    assert doc(m.def_submodule) == "TODO"

I'd try the __doc__ version first because it's stricter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added this test

};

PYBIND11_NAMESPACE_END(detail)
Expand Down
Loading