smartcall.KwOnly

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

A value that must be passed as a keyword argument.

Parameters:
  • kwarg – A single name-value pair.

  • 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 PosOnly, call
>>> def f(a):
...     return a
...
>>> call(f, KwOnly(a=1))
1