-
Notifications
You must be signed in to change notification settings - Fork 562
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
refactor(all): unify method signaturse across backends #9383
base: main
Are you sure you want to change the base?
Conversation
ACTION NEEDED Ibis follows the Conventional Commits specification for release automation. The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification. |
@pytest.mark.parametrize("base_cls, method", params) | ||
def test_signatures(base_cls, method, backend_cls): | ||
if not hasattr(backend_cls, method): | ||
pytest.skip(f"Method {method} not present in {backend_cls}, skipping...") | ||
|
||
base_sig = inspect.signature(getattr(base_cls, method)) | ||
backend_sig = inspect.signature(getattr(backend_cls, method)) | ||
|
||
assert compatible(base_sig, backend_sig, check_annotations=False) |
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 imagine we could break up the base classes into groups where we think type annotations should match vs. those where we expect some variation.
xref #8994 |
44a4bb4
to
a9cb5be
Compare
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
BREAKING CHANGE: The first argument to `read_csv` is renamed to `path` and is now a positional-only argument. All other arguments to `read_csv` are now keyword-only arguments.
BREAKING CHANGE: The first argument to `read_parquet` is renamed to `path` and is now a positional-only argument. All other arguments to `read_parquet` are now keyword-only arguments.
BREAKING CHANGE: The first argument to `read_json` is renamed to `path` and is now a positional-only argument. All other arguments to `read_json` are now keyword-only arguments.
BREAKING CHANGE: The first argument to `read_delta` is renamed to `path` and is now a positional-only argument. All other arguments to `read_delta` are now keyword-only arguments.
BREAKING CHANGE: The first argument to `create_catalog` is now a positional-only argument. All other arguments to `create_catalog` are now keyword-only arguments. BREAKING CHANGE: The first argument to `drop_catalog` is now a positional-only argument. All other arguments to `drop_catalog` are now keyword-only arguments.
BREAKING CHANGE: The first argument to `create_database` is now a positional-only argument. All other arguments to `create_database` are now keyword-only arguments. BREAKING CHANGE: The first argument to `drop_database` is now a positional-only argument. All other arguments to `drop_database` are now keyword-only arguments. BREAKING CHANGE: All arguments to `list_databases` are now keyword-only arguments.
BREAKING CHANGE: The first argument to `table` is now a positional-only argument. All other arguments to `table` are now keyword-only arguments.
BREAKING CHANGE: all arguments to `list_tables` are now keyword-only arguments. BREAKING CHANGE: The first argument to `create_table` is now a positional-only argument. BREAKING CHANGE: The first argument to `drop_table` is now a positional-only argument. BREAKING CHANGE: The first argument to `truncate_table` is now a positional-only argument. All other arguments are now keyword-only arguments.
BREAKING CHANGE: The first argument to `compile` is now a positional-only argument. All other arguments to `compile` are now keyword-only arguments.
BREAKING CHANGE: The first argument to `execute` is now a positional-only argument. All other arguments to `execute` are now keyword-only arguments.
BREAKING CHANGE: The first argument to `insert` is now a positional-only argument. The second argument, `obj`, is keyword or positional. All other arguments to `insert` are now keyword-only arguments.
We can revisit this, but for now, these can be different enough that I'm ok not enforcing strict compatibility.
BREAKING CHANGE: The first argument to `create_view` is now a positional-only argument. The second argument, `obj`, is keyword or positional. All other arguments to `create_view` are now keyword-only arguments. BREAKING CHANGE: The first argument to `drop_view` is now a postional-only argument. All other arguments to `drop_view` are now keyword-only arguments.
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.
There are still more methods to refactor in re: positional-only, and keyword-only arguments, but whether we keep the
pytest
approach for testing the signatures or not, this has proven reasonably effective at finding spots where our argument names aren't matching.I've tried to keep the various refactor commits reasonably atomic so that this isn't an absolute nightmare to review (but no one should review this yet, it isn't done).