smartcall.KwOnly

class smartcall.KwOnly(name: str, value: Any, *, required: bool = False)[source]

A value that must be passed as a keyword argument.

Parameters:
  • name – The name of the keyword argument, i.e. the “keyword” that will be used when passing this argument as a keyword argument.

  • value – The value to pass to the function.

  • required – What to do when passing this argument to a function with an incompatible signature. If True, raise an error. If False (the default), ignore it.

Example

>>> from smartcall import call, KwOnly
>>> def f(a):
...     return a
...
>>> call(f, KwOnly('a', 1))
1