Skip to content

gh-118406: Add signature for sqlite3.Connection objects #118428

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

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Lib/test/test_sqlite3/test_dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,11 @@ def test_connection_resource_warning(self):
del cx
gc_collect()

def test_connection_signature(self):
from inspect import signature
sig = signature(self.cx)
self.assertEqual(str(sig), "(sql, /)")


class UninitialisedConnectionTests(unittest.TestCase):
def setUp(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add signature for :class:`sqlite3.Connection` objects.
7 changes: 7 additions & 0 deletions Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -2561,6 +2561,12 @@ set_autocommit(pysqlite_Connection *self, PyObject *val, void *Py_UNUSED(ctx))
return 0;
}

static PyObject *
get_sig(PyObject *self, void *Py_UNUSED(ctx))
{
return PyUnicode_FromString("(sql, /)");
}


static const char connection_doc[] =
PyDoc_STR("SQLite database connection object.");
Expand All @@ -2570,6 +2576,7 @@ static PyGetSetDef connection_getset[] = {
{"total_changes", (getter)pysqlite_connection_get_total_changes, (setter)0},
{"in_transaction", (getter)pysqlite_connection_get_in_transaction, (setter)0},
{"autocommit", (getter)get_autocommit, (setter)set_autocommit},
{"__text_signature__", get_sig, (setter)0},
{NULL}
};

Expand Down