pg.typing.enable_preset_args

Accessible via pg.typing.enable_preset_args.

enable_preset_args(include_all_preset_kwargs=False, preset_name='global')[source]

Decorator for functions that maybe use preset argument values.

Usage:

@pg.typing.enable_preset_args
def foo(x, y=pg.typing.PresetArgValue(default=1)):
  return x + y

with pg.typing.preset_args(y=2):
  print(foo(x=1))  # 3: y=2
print(foo(x=1))  # 2: y=1
Return type:

Callable[[FunctionType], FunctionType]

Parameters:
  • include_all_preset_kwargs – Whether to include all preset kwargs (even not makred as PresetArgValue) when callng the function.

  • preset_name – The name of the preset to specify kwargs.

Returns:

A decorated function that could consume the preset argument values.