How to spell type signatures for default argument?

PR#7980 proposes a change to how type signatures are spelled for arguments with default values.

For example,

@njit("int16(int16, optional(int16), optional(int16))")
def foo(x, y=2, z=None):

Without the PR and without the type signature, the code currently uses Omitted types:

In [5]: @njit
   ...: def foo(x, y=2, z=None):
   ...:     if z is None:
   ...:         z = 3
   ...:     return x + y + z

In [6]: foo(1)
Out[6]: 6

In [7]: foo(1, 2)
Out[7]: 6

In [8]: foo(1, 2, 3)
Out[8]: 6

In [9]: foo.signatures
[(int64, omitted(default=2), omitted(default=None)),
 (int64, int64, omitted(default=None)),
 (int64, int64, int64)]

The PR use of optional(int16) for y=2 seems to change the meaning of the optional type.

Would the following spelling be better?

@njit("int16(int16, int16, optional(int16))")
def foo(x, y=2, z=None):

So, the optional type meaning is unchanged and Numba should just check for default arguments regardless of the type signature.

This is discussed in today’s meeting and a feature request is created for the above proposed change: Type signature spelling for arguments with default values · Issue #8950 · numba/numba · GitHub