-
Notifications
You must be signed in to change notification settings - Fork 6
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
Closes #469 fix_assert_list_element: consider ... for evaluation of message #470
base: main
Are you sure you want to change the base?
Conversation
@manciniedoardo , this one is environment related. So a good preparation for our working group. |
#' @param ... Objects required to evaluate the condition | ||
#' If the condition contains objects apart from the element, they have to be | ||
#' passed to the function. See the second example below. | ||
#' @param ... Objects required to evaluate the condition or the message text |
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.
So is the traditional way to use ...
. I remember there was some discussion during argument renaming days that this was not standard convention??
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.
I feel like it is the standard way but I have never used this before - does it need so much flexibility?
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.
wait - now i am backtracking!
) | ||
} | ||
|
||
cli_abort( | ||
message = message, | ||
class = c(class, "assert-admiraldev"), | ||
.envir = env(...), |
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.
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.
When we started, it was suggested not to include an envir
argument for simplicity. In the generic checking functions I maintain, I prefer to expose the environment control just in case, for example:
check_class <- function(x,
cls,
allow_empty = FALSE,
message,
arg_name = rlang::caller_arg(x),
class = "check_class",
call = get_cli_abort_call(),
envir = rlang::current_env()) { # ENVIR ARGUMENT IS HERE AND IS PASSED TO cli_abort()
# if empty, skip test
if (isTRUE(allow_empty) && rlang::is_empty(x)) {
return(invisible(x))
}
if (!inherits(x, cls)) {
cli::cli_abort(message, class = c(class, "standalone-checks"), call = call, .envir = envir)
}
invisible(x)
}
We could do the same here
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.
I think this would work for assert_list_element()
. However, if we add the envir
argument here, we should add it for all assertions. This would be a lot of work. We would not only need to add the argument but also revise and update the code of the assertions because in some assertions the message text uses objects which are created in the assertion function.
Thus I would not add the envir
argument.
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.
okay sounds good to not add
Thank you for your Pull Request! We have developed this task checklist from the Development Process Guide to help with the final steps of the process. Completing the below tasks helps to ensure our reviewers can maximize their time on your code as well as making sure the admiral codebase remains robust and consistent.
Please check off each taskbox as an acknowledgment that you completed the task or check off that it is not relevant to your Pull Request. This checklist is part of the Github Action workflows and the Pull Request will not be merged into the
main
branch until you have checked off each task.styler::style_file()
to style R and Rmd filesdevtools::document()
so all.Rd
files in theman
folder and theNAMESPACE
file in the project root are updated appropriatelyNEWS.md
under the header# admiral (development version)
if the changes pertain to a user-facing function (i.e. it has an@export
tag) or documentation aimed at users (rather than developers)pkgdown::build_site()
and check that all affected examples are displayed correctly and that all new functions occur on the "Reference" page.lintr::lint_package()
R CMD check
locally and address all errors and warnings -devtools::check()