From 531424c8c127c3017405f4a1d25014fcdf7cdf5c Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 9 Oct 2021 17:55:52 -0700 Subject: [PATCH] Remove *args, force use of named arguments. --- voussoirkit/operatornotify.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/voussoirkit/operatornotify.py b/voussoirkit/operatornotify.py index 085ba94..7cdc1ce 100644 --- a/voussoirkit/operatornotify.py +++ b/voussoirkit/operatornotify.py @@ -220,7 +220,7 @@ def get_level_by_argv(argv): return (argv, level) -def main_decorator(subject, *args, **kwargs): +def main_decorator(subject, **kwargs): ''' Add this decorator to your application's main function to automatically wrap it in a main_log_context and log the final return value. For example: @@ -241,7 +241,7 @@ def main_decorator(subject, *args, **kwargs): def wrapper(main): def wrapped(argv): (argv, level) = get_level_by_argv(argv) - context = main_log_context(subject, level, *args, **kwargs) + context = main_log_context(subject, level, **kwargs) # We need to call basic_config so that operatornotify's logs have # somewhere to go. We do this only during wrapped, not before, so @@ -260,7 +260,7 @@ def main_decorator(subject, *args, **kwargs): return wrapped return wrapper -def main_log_context(subject, level, *args, **kwargs): +def main_log_context(subject, level, **kwargs): ''' Returns a context manager with which you'll wrap your function. Will be nullcontext if the level is None (user did not opt in). @@ -271,14 +271,14 @@ def main_log_context(subject, level, *args, **kwargs): that kills your function. 3. Results are sent at the end of the context, when your function returns. - Additional *args, **kwargs go to LogHandler init, so you can + Additional **kwargs go to LogHandler init, so you can pass notify_every_line, etc. ''' if level is None: return contextlib.nullcontext() log = vlogging.getLogger() - handler = LogHandler(subject, *args, **kwargs) + handler = LogHandler(subject, **kwargs) handler.setLevel(level) handler.setFormatter(vlogging.Formatter('{levelname}:{name}:{message}', style='{')) context = LogHandlerContext(log, handler)