Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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(types): provide better type hints for a variety of generic types #4259
fix(types): provide better type hints for a variety of generic types #4259
Changes from all commits
88824b5
33f9bac
5f8b132
1685758
ccaeb52
f9d8694
072049a
8e6b00f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
I think this feature will be clearer as such by having the types below in a
typing
sub-namespace.I'm not sure about (e.g.)
py::typing::Tuple
vspy::typing::tuple
. Pure Pythontyping.tuple
does not exist (I tried with Python 3.11), therefore I'm guessingpy::typing::Tuple
might be less surprising.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.
Could this be
template <typename... Types>
like orTuple
?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.
Update: I just ran this by a typing expert on my team, from that I learned:
Is that too tricky to implement for this PR?
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.
IMO,
list[float | str]
is fine / best, that's valid for older versions of Python as long as you only use it for typing and not at runtime.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.
Also, the equivalent for
tuple
istuple[float | str, ...]
.tuple[float, str]
is a size 2 tuple with a float as the first item, and a str as the second.