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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gentlegiantJGC
Copy link
Contributor

Description

"module" is not a valid python value.
The correct type hint for a module object is "types.ModuleType" which has existed since at least Python 2.6

Suggested changelog entry:

Fix module type hint

"module" is not a valid python value.
The correct type hint for a module object is "types.ModuleType" which has existed since at least Python 2.6
@@ -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.

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