-
Notifications
You must be signed in to change notification settings - Fork 631
test(sigcheck): check function signature parity across backends #10008
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
This is a fork of some of the utilities in Scott Sanderson's `python-interface` project (https://github.com/ssanderson/python-interface). While the upstream is no longer maintained, the goal of that project aligns quite well with some of the issues we face with maintaining consistent interfaces across backends. I'm grabbing a few of these utilities and ripping out Python 2 support, then I'm going to work on setting up tests for making sure that backend methods match the signatures in the parent `BaseBackend` class.
Should be `implementation, interface_def`, not the other way around
"to_parquet_dir", | ||
marks=pytest.mark.notyet(["pyspark"]), | ||
), | ||
"truncate_table": pytest.param( |
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.
So, basically the goal is to, over time, remove as many elements of this dict as possible?
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.
Ideally, we'd remove all of them. There's a more generic "skip for all backends" list for things like do_connect
, but I think we should be able to remove all of the entries in this dict if we standardize positional keyword names, and enforce keyword-only arguments
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, once this is merged in, it will also prevent us from adding new methods with differing argument names (assuming those methods are defined in the base classes, which they should be)
…-project#10008) Opening this in favor of ibis-project#9383 -- that PR also included all of the breaking changes to unify function signatures and it was too much at once. This PR adds only the signature checking mechanism, plus the requisite xfails to lay out which inconsistencies are currently in Ibis. ## Motivation We want to ensure that, for a given backend, that the argument names, plus usage of positional, positional-only, keyword, and keyword-only arguments match, so that there is API consistency when moving between backends. I've grabbed a few small parts of some of the utilities in Scott Sanderson's `python-interface` project (https://github.com/ssanderson/python-interface). While the upstream is no longer maintained, the goal of that project aligns quite well with some of the issues we face with maintaining consistent interfaces across backends. Note that while the upstream project focused on _runtime_ enforcement of these signatures matching, here it is only run in the test suite. ## Rough procedure Any method that doesn't match can be skipped entirely (this is useful for things like `do_connect`, which cannot reasonably be assumed to match) or individually (by specifying a `pytest.param` and marking the failing backends). Then we scrape across the common parent classes and add any methods that are NOT currently specified in the pre-existing xfailed ones. It's a bit of a nuisance, but it's done, and ideally the manual listing of the inconsistent methods goes away as we unify things. I've opted for not checking that type annotations match, because that seems... unreasonable. This would satisfy ibis-project#9125 once all of the xfail markers are removed, e.g., it checks that all keyword and positional arguments are standardized.
Opening this in favor of #9383 -- that PR also included all of the breaking changes to unify function signatures and it was too much at once. This PR adds only the signature checking mechanism, plus the requisite xfails to lay out which inconsistencies are currently in Ibis.
Motivation
We want to ensure that, for a given backend, that the argument names, plus usage of positional, positional-only, keyword, and keyword-only arguments match, so that there is API consistency when moving between backends.
I've grabbed a few small parts of some of the utilities in Scott Sanderson's
python-interface
project (https://github.com/ssanderson/python-interface).While the upstream is no longer maintained, the goal of that project
aligns quite well with some of the issues we face with maintaining
consistent interfaces across backends.
Note that while the upstream project focused on runtime enforcement of these signatures matching, here it is only run in the test suite.
Rough procedure
Any method that doesn't match can be skipped entirely (this is useful for things like
do_connect
, which cannot reasonably be assumed to match) or individually (by specifying apytest.param
and marking the failing backends).Then we scrape across the common parent classes and add any methods that are NOT currently specified in the pre-existing xfailed ones. It's a bit of a nuisance, but it's done, and ideally the manual listing of the inconsistent methods goes away as we unify things.
I've opted for not checking that type annotations match, because that seems... unreasonable.
This would satisfy #9125 once all of the xfail markers are removed, e.g., it checks that all keyword and positional arguments are standardized.