-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Clean up sqlite3.Connection APIs #108278
Comments
Deprecate passing name, number of arguments, and the callable as keyword arguments, for the following sqlite3.Connection APIs: - create_function(name, nargs, callable, ...) - create_aggregate(name, nargs, callable) Deprecate passing the callback as a keyword argument, for the following sqlite3.Connection APIs: - set_authorizer(callback) - set_progress_handler(callback, n) - set_trace_callback(callback) The affected parameters will become positional-only in Python 3.15.
Why keep |
I did consider it, and I'm still considering it :) I'm not sure what makes for the better API.
|
Or maybe On other hand, So I am not sure about these changes. On other hand, having different names Alternatively we can rename keyword arguments with keeping deprecated alias (#108271), but first we need to agree on names. It is easier to simply deprecate passing by keyword. |
Yes, it is easier to deprecate passing by keyword, and I also think it makes for a cleaner API. Regarding similarity to SQLite C API; I'm not sure it makes sense to align our APIs with those of SQLite. The sqlite3 extension module is a DB API implementation; it does not aim to be a Python shim over the SQLite C API (like apsw). I'll split my PR in two, so there is one PR for each API group; it will be easier to reason about. |
I agree; generally, I'm not a big fan of 1-letter variable/parameter names. |
…or sqlite3 UDF creation APIs (#108281) Deprecate passing name, number of arguments, and the callable as keyword arguments, for the following sqlite3.Connection APIs: - create_function(name, nargs, callable, ...) - create_aggregate(name, nargs, callable) The affected parameters will become positional-only in Python 3.15.
…args for sqlite3 UDF creation APIs (python#108281) Deprecate passing name, number of arguments, and the callable as keyword arguments, for the following sqlite3.Connection APIs: - create_function(name, nargs, callable, ...) - create_aggregate(name, nargs, callable) The affected parameters will become positional-only in Python 3.15.
…ion callback APIs by keyword Deprecate passing the callback callable by keyword for the following sqlite3.Connection APIs: - set_authorizer(authorizer_callback) - set_progress_handler(progress_handler, ...) - set_trace_callback(trace_callback) The affected parameters will become positional-only in Python 3.15.
@serhiy-storchaka, I created a PR for the callback handlers. You raised a question regarding the Regarding the latter, I already replied that I don't think the order of parameters in the SQLite C API should be directing the order of parameters in the sqlite3 API; the sqlite3 module is not apsw. Regarding my suggested omission of the
Also, the docstring of |
…llback APIs by keyword (#108632) Deprecate passing the callback callable by keyword for the following sqlite3.Connection APIs: - set_authorizer(authorizer_callback) - set_progress_handler(progress_handler, ...) - set_trace_callback(trace_callback) The affected parameters will become positional-only in Python 3.15.
Thanks for your input and reviews, Serhiy. |
* main: pythongh-108520: Fix bad fork detection in nested multiprocessing use case (python#108568) pythongh-108590: Revert pythongh-108657 (commit 400a1ce) (python#108686) pythongh-108494: Argument Clinic: Document how to generate code that uses the limited C API (python#108584) Document Python build requirements (python#108646) pythongh-101100: Fix Sphinx warnings in the Logging Cookbook (python#108678) Fix typo in multiprocessing docs (python#108666) pythongh-108669: unittest: Fix documentation for TestResult.collectedDurations (python#108670) pythongh-108590: Fix sqlite3.iterdump for invalid Unicode in TEXT columns (python#108657) Revert "pythongh-103224: Use the realpath of the Python executable in `test_venv` (pythonGH-103243)" (pythonGH-108667) pythongh-106320: Remove private _Py_ForgetReference() (python#108664) Mention Ellipsis pickling in the docs (python#103660) Revert "Use non alternate name for Kyiv (pythonGH-108533)" (pythonGH-108649) pythongh-108278: Deprecate passing the first param of sqlite3.Connection callback APIs by keyword (python#108632) pythongh-108455: peg_generator: install two stubs packages before running mypy (python#108637) pythongh-107801: Improve the accuracy of io.IOBase.seek docs (python#108268)
Feature or enhancement
Has this already been discussed elsewhere?
https://discuss.python.org/t/clean-up-some-sqlite3-apis/32093
Links to previous discussion of this feature:
#87260 (comment)
Proposal:
The sqlite3.Connection class has groups of similar APIs with inconsistent parameter specs.
Create user-defined function APIs:
create_function(name, narg, func, *, deterministic=False)
create_aggregate(name, /, n_arg, aggregate_class)
create_window_function(name, num_params, aggregate_class, /)
create_collation(name, callable, /)
Set callback APIs:
set_authorizer(authorizer_callback)
set_progress_handler(progress_handler, n)
set_trace_callback(trace_callback)
For all APIs but
create_function
, I suggest to make all parameters positional-only; forcreate_function
, I suggest to make the three first parameters positional-only:Create user-defined function APIs:
create_function(name, nargs, callable, /, *, deterministic=False)
create_aggregate(name, nargs, aggregate_class, /)
create_window_function(name, nargs, aggregate_class, /)
create_collation(name, callable, /)
Set callback APIs:
set_authorizer(authorizer_callback, /)
set_progress_handler(progress_handler, /, n)
set_trace_callback(trace_callback, /)
Obviously,
create_window_function
stays as it is.UPDATE: I noticed the docs are wrong about
create_collation
; it's signature is actuallycreate_collation(name, callable, /)
.Linked PRs
The text was updated successfully, but these errors were encountered: