-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Provide signatures to some C-level classes and methods. #15009
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
Conversation
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.
+1 for the signature changes.
-0.5 for the changes to the tests. I think they should be pytest.raises(TypeError, match=...)
.
lib/matplotlib/tests/test_figure.py
Outdated
@@ -382,9 +383,8 @@ def test_subplots_shareax_loglabels(): | |||
|
|||
def test_savefig(): | |||
fig = plt.figure() | |||
msg = r"savefig\(\) takes 2 positional arguments but 3 were given" | |||
with pytest.raises(TypeError, match=msg): |
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'm not sure that these replacements are beneficial to the tests. Understanding bind is more difficult and less readable.
I agree with @timhoffm; the test is there to confirm that if a user runs |
Compare e.g. an excerpt of the docs of matplotlib._tri.Triangulation before ``` | calculate_plane_coefficients(...) | calculate_plane_coefficients(z, plane_coefficients) | | Calculate plane equation coefficients for all unmasked triangles | | get_edges(...) | get_edges() | | Return edges array ``` and after ``` | calculate_plane_coefficients(z, plane_coefficients) | Calculate plane equation coefficients for all unmasked triangles | | get_edges() | Return edges array ``` The convention of using "func_name(arg, ...)--\n\n" for C-level signatures is admittedly undocumented, but comes from https://bugs.python.org/issue20530.
ok, reverted the tests change |
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.
When tests pass
Compare e.g. an excerpt of the docs of matplotlib._tri.Triangulation
before
and after
This means that inspect.signature() now knows about the correct
signature, and signature tests can use inspect.signature().bind rather
than matching on the error string.
The convention of using "func_name(arg, ...)--\n\n" for
C-level signatures is admittedly undocumented, but comes from
https://bugs.python.org/issue20530.
Inspired by the need to update error message strings in #14964 (although this would not have helped because Py2 doesn't support inspect.signature, but heh).
PR Summary
PR Checklist