# Signatures, a call to action

**URL:** <https://discuss.python.org/t/signatures-a-call-to-action/23580>\
**Category:** Core Development\
**Created:** [February 6, 2023, 3:23am UTC](https://discuss.python.org/t/signatures-a-call-to-action/23580 "2023-02-06T03:23:34Z")\
**Posts on this page:** 1\
**Showing post:** 19

<div class="post-metadata">

**Author:** ![rhettinger](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/rhettinger/32/1129_2.png) [@rhettinger](https://discuss.python.org/u/rhettinger)\
**Post date:** [February 6, 2023, 10:01pm UTC](https://discuss.python.org/t/signatures-a-call-to-action/23580/19 "2023-02-06T22:01:10Z")

</div>

> [@steve.dower](#):
>
> Those of us who were around before argument clinic was added know what the signatures were before then. And so we know that the only reason they “don’t fit” into AC is because it hasn’t been finished.
> 
> But anyone who only started looking _after_ AC was widely implemented is going to have to figure out for themselves which signature is “correct”. And the tendency of developers is to move towards the most concrete unification system possible.

Yes. Exactly this. We see this occur over and over.

Here is a concrete proposal to kick off the conversation about how to complete the Argument Clinic and stop having to live with an incomplete tool.

Given that our documentation DSL can already describe optional arguments `getattr(object, name[, default])` and that the type annotation DSL can already describe the function using overloads, let’s modify arg clinic to be able to describe and generate code for a union of signatures:

```auto
/*[clinic input]
getattr as builtin_getattr2

    object: object
    name: str
    /

getattr as builtin_getattr3

    object: object
    name: str
    default: object
    /

Get a named attribute from an object; getattr(x, 'y') is equivalent to x.y.

When a default argument is given, it is returned when the attribute doesn't
exist; without it, an exception is raised in that case.
[clinic start generated code -- signature 1]*/

static PyObject *
builtin_getattr2(PyObject *module, PyObject *object, PyString_Object *str)
/*[clinic end generated code: output=b1b433b9e51356f5 input=bed4ca14e29c20d1]*/

[clinic start generated code -- signature 2]*/

static PyObject *
builtin_getattr3(PyObject *module, PyObject *object, PyString_Object *str, PyObject *default)
/*[clinic end generated code: output=b1b433b9e51356f5 input=bed4ca14e29c20d1]*/

```

Having a union of signatures would work super well for functions where `None` can’t be used like `getattr` and `dict.pop` for cases where `None` is merely undesirable such as `type(object)` vs `type(name, bases, dict, **kwds)` or `range(stop)` vs `range(start, stop[, step])`.

---

_[View the full topic](https://discuss.python.org/t/signatures-a-call-to-action/23580)._
