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

This commit is contained in:
Erlend E. Aasland 2024-04-30 21:58:22 +02:00 committed by GitHub
parent 19d468a3ab
commit b568c2c1ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 0 deletions

View File

@ -590,6 +590,11 @@ class ConnectionTests(unittest.TestCase):
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):

View File

@ -0,0 +1 @@
Add signature for :class:`sqlite3.Connection` objects.

View File

@ -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.");
@ -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}
};