-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make sure there are no unknown named arguments fix #140 #141
Conversation
f0a9c35
to
81d31ef
Compare
#' @keywords internal | ||
assert_no_unknown_args <- function() { | ||
call <- match.call(definition = sys.function(1), call = sys.call(1), expand.dots = FALSE) | ||
stopifnot("Unknown named argument provided." = is.null(names(call$`...`))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe better to supply the argument(s)?
stopifnot("Unknown named argument provided." = is.null(names(call$`...`))) | |
if (!is.null(unknown_names <- names(call$`...`))) { | |
stop("Unknown argument(s) provided: ", toString(unknown_names)) | |
} |
After taking a look at the test results, and thinking this through more, I think failing on named args is not a viable solution, as there are many valid cases to pass named args, e.g. when using JSON loggers, or the below dummy example: log_info('Hello, {v}!', v = 'world')
INFO [2024-02-29 00:26:30] Hello, world! |
hmm, in that case, maybe it's the description of '...' that's misleading? Line 214 in ec619ce
|
I'm not sure if that's misleading, but suggestions welcomed. Formatters take the args and convert to string. Some formatters support named args .. but those are still R objects. If it's confusing, pls suggest better language 🙏 |
My initial read is that something like This is an instructive example I think: log_info('{a}', '{a}{b}', '{a}{b}{c}', a=1, b=2, c=3)
# INFO [2024-02-28 16:21:37] 112123 |
No description provided.