Repository navigation
sqlite3 signature discrepancies between documentation and implementation #87260
Description
Activity
The doc for sqlite3.create_function shows the signature as follows:
https://docs.python.org/3.9/library/sqlite3.html#sqlite3.Connection.create_function
create_function(name, num_params, func, *, deterministic=False)But it appears that the parameter name is
narg, notnum_params. Tryingnum_paramsyields:TypeError: function missing required argument 'narg' (pos 2)- addeddocsDocumentation in the Doc dirDocumentation in the Doc dir3.9 (EOL)end of lifeend of life
on Feb 1, 2021 There's also a discrepancy between the docs and the signature for create_aggregate():
https://docs.python.org/3.9/library/sqlite3.html#sqlite3.Connection.create_aggregate
create_aggregate(name, num_params, aggregate_class)
The second parameter is named n_arg, here with an underscore.
I'm not sure what's the best fix; fixing the docs or the signatures. If we fix the signatures, we'll at least get a kind of consistency.
Quoting from Victor Stinner's reply on python-dev (https://mail.python.org/archives/list/python-dev@python.org/message/X6SZIVOZ233TLLJV43UQEHMV3ELGP34S/):
If there are applications relying on the parameter name, it's better
to trust the Python implementation, rather than the documentation.It would be better to make these parameters positional only in the
first place, but now it's too late for such backward incompatible
change :-(Module level function discrepancies:
register_converter(), register_adapter(), and enable_callback_tracebacks() docstrings were unintentionally altered in recent AC updates. Docstrings should be restored. Docs are ok.
adapt() is not documented, but docstrings were unintentionally altered in recent AC updates. Docstrings should be restored.
connect() and enable_shared_cache() (latter is undocumented) are ok.
complete_statement() docs should be updated to reflect implementation.
- changed the title
[-]sqlite3.create_function takes parameter named narg, not num_params[/-][+]Update sqlite3 docs and docstrings to reflect implementation[/+]on Feb 9, 2021 - changed the title
[-]sqlite3.create_function takes parameter named narg, not num_params[/-][+]Update sqlite3 docs and docstrings to reflect implementation[/+]on Feb 9, 2021 sqlite3.Connection.set_progress_handler()
docs: set_progress_handler(handler, n)
impl: set_progress_handler(progress_handler, n)Apart from that, the rest of sqlite3.Connection seems to be ok.
There's an ongoing discussion at python-dev about how to resolve this issue. I'm in favour of normalising the create_*() methods to be positional only (like create_collation() is now).
sqlite3.Cursor and sqlite3.Row methods seems to be ok as well.
8 remaining items
The problem is that sqlite3 isn't the only module where there are discrepancies between documentation and implementation.
This does not stand in the way of fixing the docs right away.
If we are going to change public sqlite3 APIs in to be positional-only, I'd prefer writing a PEP and fix all modules once and for all.
I think that is too large for a PEP. We could create an issue for making some sqlite3 methods positional only. See also gh-93057.
- added a commit that references this issue
on Jun 15, 2022 Thanks for the report. If there are further discrepancies, please open a new issue.
For making sqlite3 methods positional only, please open a new issue.
- added a commit that references this issue
on Jun 26, 2022 FTR, I did start drafting a PEP back in 2021, but I abandoned the project as I found it to be too vague for a PEP, in my opinion.
Reacted by Serhiy Storchaka
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: