PyDoc: use Python's type annotation syntax for doc-strings

Replace plain-text type information with the type syntax used
for Python's type annotations as it's more concise, especially for
callbacks which often didn't include useful type information.

Note that this change only applies to inline doc-strings,
generated doc-strings from RNA need to be updated separately.

Details:

- Many minor corrections were made when "list" was incorrectly used
  instead of "sequence".
- Some type information wasn't defined in the doc-strings and has been
  added.
- Verbose type info would benefit from support for type aliases.
This commit is contained in:
Campbell Barton
2024-11-03 15:42:19 +11:00
parent 3347aa4017
commit 3bcfb151c1
90 changed files with 722 additions and 676 deletions

View File

@@ -115,7 +115,7 @@ PyDoc_STRVAR(
" Insert a point into the KDTree.\n"
"\n"
" :arg co: Point 3d position.\n"
" :type co: float triplet\n"
" :type co: Sequence[float]\n"
" :arg index: The index of the point.\n"
" :type index: int\n");
static PyObject *py_kdtree_insert(PyKDTree *self, PyObject *args, PyObject *kwargs)
@@ -202,13 +202,13 @@ PyDoc_STRVAR(
"\n"
" Find nearest point to ``co``.\n"
"\n"
" :arg co: 3d coordinates.\n"
" :type co: float triplet\n"
" :arg co: 3D coordinates.\n"
" :type co: Sequence[float]\n"
" :arg filter: function which takes an index and returns True for indices to "
"include in the search.\n"
" :type filter: callable\n"
" :return: Returns (:class:`Vector`, index, distance).\n"
" :rtype: :class:`tuple`\n");
" :type filter: Callable[[int], bool]\n"
" :return: Returns (position, index, distance).\n"
" :rtype: tuple[:class:`Vector`, int, float]\n");
static PyObject *py_kdtree_find(PyKDTree *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_co, *py_filter = nullptr;
@@ -259,12 +259,12 @@ PyDoc_STRVAR(
"\n"
" Find nearest ``n`` points to ``co``.\n"
"\n"
" :arg co: 3d coordinates.\n"
" :type co: float triplet\n"
" :arg co: 3D coordinates.\n"
" :type co: Sequence[float]\n"
" :arg n: Number of points to find.\n"
" :type n: int\n"
" :return: Returns a list of tuples (:class:`Vector`, index, distance).\n"
" :rtype: :class:`list`\n");
" :return: Returns a list of tuples (position, index, distance).\n"
" :rtype: list[tuple[:class:`Vector`, int, float]]\n");
static PyObject *py_kdtree_find_n(PyKDTree *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_list;
@@ -315,12 +315,12 @@ PyDoc_STRVAR(
"\n"
" Find all points within ``radius`` of ``co``.\n"
"\n"
" :arg co: 3d coordinates.\n"
" :type co: float triplet\n"
" :arg co: 3D coordinates.\n"
" :type co: Sequence[float]\n"
" :arg radius: Distance to search for points.\n"
" :type radius: float\n"
" :return: Returns a list of tuples (:class:`Vector`, index, distance).\n"
" :rtype: :class:`list`\n");
" :return: Returns a list of tuples (position, index, distance).\n"
" :rtype: list[tuple[:class:`Vector`, int, float]]\n");
static PyObject *py_kdtree_find_range(PyKDTree *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_list;