-
Notifications
You must be signed in to change notification settings - Fork 784
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
add #[pyo3(signature = (...))]
attribute
#2702
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The issue number of the news fragments (2302) does not match the PR issue number (2702) which is why that CI job fails. |
Thanks for the review - addressed both comments. |
birkenfeld
approved these changes
Oct 22, 2022
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.
Perfect, the new syntax is so much nicer!
davidhewitt
force-pushed
the
signature
branch
from
October 22, 2022 11:32
3b07bae
to
741a07f
Compare
davidhewitt
force-pushed
the
signature
branch
from
October 22, 2022 11:36
741a07f
to
0be85dc
Compare
davidhewitt
force-pushed
the
signature
branch
from
October 22, 2022 11:48
0be85dc
to
c88e336
Compare
davidhewitt
force-pushed
the
signature
branch
from
October 22, 2022 12:41
c88e336
to
417e468
Compare
bors bot
added a commit
that referenced
this pull request
Nov 22, 2022
2739: error when `#[pyo3(signature = ())]` used on invalid methods r=davidhewitt a=davidhewitt A follow-up to #2702 to reject some invalid applications of `#[pyo3(signature = (...))]` attribute, specifically on magic methods and getters / setters / class attributes. Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
bors bot
added a commit
that referenced
this pull request
Jan 15, 2023
2703: deprecate required argument after `Option<T>` without signature r=davidhewitt a=davidhewitt This PR is a follow-up to #2702 to make required arguments after `Option<T>` arguments require a `#[pyo3(signature)]` annotation to remove the possible ambiguity on whether the developer actually wanted to have a required option (which is what PyO3 is currently forced to assume). Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
mr-eyes
added a commit
to sourmash-bio/sourmash_plugin_branchwater
that referenced
this pull request
Jul 24, 2024
mr-eyes
added a commit
to sourmash-bio/sourmash_plugin_branchwater
that referenced
this pull request
Aug 17, 2024
* following pyp3 sig from PyO3/pyo3#2702 * initialy working * writing to a sourmash sig instead * now faster * fix * [WIP] optional save-matches * [DONE] optional save-matches fastmultigather * add a simple test * fix name * doc * f,t * Remove test line * resolve comments * resolve comments * remove testing line * MRG: update `--save-matches` code a bit. (#420) * add pyo3 decoration * do not ignore result * fix fmt * remove redundant * MRG: more updates for `--save-matches` (#423) * make use of in_directory * add more tests --------- Co-authored-by: C. Titus Brown <titus@idyll.org>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is an implementation of the proposal in #2193 to add a new
#[pyo3(signature = (...))]
attribute to specify function arguments.This PR also deprecates the old way of setting function argument signatures.
Compared to
#[pyfunction(...)]
/#[args(...)]
:signature = (...)
compared to different forms for#[pyfunction]
and#[pymethods]
.*args
instead ofargs = "*"
.signature(name = "David")
instead ofargs(name = "\"David\"")
The possible argument I can see which could be made against this is the increased verbosity from requiring all arguments to appear. I argue this is a plus to ensure correctness. It would be easy to relax this in future if feedback frequently requested it.
Future extensions:
text_signature
automaticallysignature = (a: int = 5, b: str = "hello")
, although the mechanism how the type annotations would be exposed is still unclear.To review this, I suggest looking at the guide and tests, and if you're satisfied with that give the implementation a scan.