-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add typing and collections.abc module prefix #5663
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
base: master
Are you sure you want to change the base?
Conversation
These type hints are invalid in Python 3.8. Add `typing.` prefix to remove ambiguity.
The tests need updating to reflect these changes. |
@InvincibleRMC, thoughts? |
I think this is a good idea. This was discussed a little in and around #5566 (comment). Adding the module prefix will allow users to create their own |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, but do we actually still want to support Python 3.8?
Python 3.8 EOL was 2024-10-07
include/pybind11/detail/common.h
Outdated
@@ -239,6 +239,27 @@ | |||
# define PYBIND11_SUBINTERPRETER_SUPPORT | |||
#endif | |||
|
|||
// 3.9 Compatibility | |||
#if 0x03090000 <= PY_VERSION_HEX | |||
# define PYBIND11_ITERABLE_TYPE_HINT "collections.abc.Iterable" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion to make these
PYBIND11_TYPE_HINT_...
so they line up nicely and are easier to pin-point.
include/pybind11/detail/common.h
Outdated
@@ -239,6 +239,27 @@ | |||
# define PYBIND11_SUBINTERPRETER_SUPPORT | |||
#endif | |||
|
|||
// 3.9 Compatibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Python 3.9+ Compatibility
?
(The +
is the most important aspect of my suggestion.)
You still have test runners for 3.8 so I assumed you still supported it. |
Me: yes But I'll go with @henryiii's judgement. |
Let's keep it for 3.0. We can drop it for 3.1. |
It's in setup.cfg (or pyproject.toml after #5598) |
I think I am going to scale back this pull request to just adding the module prefix. |
Fixing this issue in Python 3.8 will require updating lots of tests. This can be added in a further pull request.
I have fixed the tests. |
Description
Add
typing.
andcollections.abc
prefix to remove ambiguity.Suggested changelog entry: