Skip to content
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

Update standalone files + standardize snapshot tests #1579

Merged
merged 11 commits into from
Oct 25, 2024
3 changes: 2 additions & 1 deletion R/append.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ df_append <- function(x, y, after = NULL, remove = FALSE) {
after <- match(after, x_names)
}

check_number_whole(after, min = 0L, max = n, .internal = TRUE)
# r-lib/rlang#1702
check_number_whole(after, min = 0, max = as.numeric(n), .internal = TRUE)

if (remove) {
lhs <- seq2(1L, after - 1L)
Expand Down
21 changes: 16 additions & 5 deletions R/compat-lazyeval.R → R/import-standalone-lazyeval.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
# nocov start - compat-lazyeval (last updated: rlang 0.3.0)

# Standalone file: do not edit by hand
# Source: https://github.com/r-lib/rlang/blob/HEAD/R/standalone-lazyeval.R
# Generated by: usethis::use_standalone("r-lib/rlang", "lazyeval")
# ----------------------------------------------------------------------
#
# ---
# repo: r-lib/rlang
# file: standalone-lazyeval.R
# last-updated: 2018-09-18
# license: https://unlicense.org
# imports: rlang
# ---
#
# This file serves as a reference for compatibility functions for lazyeval.
# Please find the most recent version in rlang's repository.

#
# nocov start

warn_underscored <- function() {
return(NULL)
Expand Down Expand Up @@ -48,7 +59,7 @@ compat_lazy <- function(lazy, env = caller_env(), warn = TRUE) {
},
list =
if (inherits(lazy, "lazy")) {
lazy <- new_quosure(lazy$expr, lazy$env)
lazy = new_quosure(lazy$expr, lazy$env)
}
)

Expand Down
45 changes: 35 additions & 10 deletions R/compat-obj-type.R → R/import-standalone-obj-type.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
# nocov start --- r-lib/rlang compat-obj-type
# Standalone file: do not edit by hand
# Source: https://github.com/r-lib/rlang/blob/HEAD/R/standalone-obj-type.R
# Generated by: usethis::use_standalone("r-lib/rlang", "obj-type")
# ----------------------------------------------------------------------
#
# Changelog
# =========
# ---
# repo: r-lib/rlang
# file: standalone-obj-type.R
# last-updated: 2024-02-14
# license: https://unlicense.org
# imports: rlang (>= 1.1.0)
# ---
#
# ## Changelog
#
# 2024-02-14:
# - `obj_type_friendly()` now works for S7 objects.
#
# 2023-05-01:
# - `obj_type_friendly()` now only displays the first class of S3 objects.
#
# 2023-03-30:
# - `stop_input_type()` now handles `I()` input literally in `arg`.
#
# 2022-10-04:
# - `obj_type_friendly(value = TRUE)` now shows numeric scalars
Expand Down Expand Up @@ -36,7 +55,8 @@
# - Added support for matrices and arrays (#141).
# - Added documentation.
# - Added changelog.

#
# nocov start

#' Return English-friendly type
#' @param x Any R object.
Expand All @@ -55,7 +75,7 @@ obj_type_friendly <- function(x, value = TRUE) {
if (inherits(x, "quosure")) {
type <- "quosure"
} else {
type <- paste(class(x), collapse = "/")
type <- class(x)[[1L]]
}
return(sprintf("a <%s> object", type))
}
Expand Down Expand Up @@ -251,19 +271,19 @@ vec_type_friendly <- function(x, length = FALSE) {
#' Return OO type
#' @param x Any R object.
#' @return One of `"bare"` (for non-OO objects), `"S3"`, `"S4"`,
#' `"R6"`, or `"R7"`.
#' `"R6"`, or `"S7"`.
#' @noRd
obj_type_oo <- function(x) {
if (!is.object(x)) {
return("bare")
}

class <- inherits(x, c("R6", "R7_object"), which = TRUE)
class <- inherits(x, c("R6", "S7_object"), which = TRUE)

if (class[[1]]) {
"R6"
} else if (class[[2]]) {
"R7"
"S7"
} else if (isS4(x)) {
"S4"
} else {
Expand All @@ -288,7 +308,7 @@ stop_input_type <- function(x,
show_value = TRUE,
arg = caller_arg(x),
call = caller_env()) {
# From compat-cli.R
# From standalone-cli.R
cli <- env_get_list(
nms = c("format_arg", "format_code"),
last = topenv(),
Expand All @@ -305,10 +325,15 @@ stop_input_type <- function(x,
if (length(what)) {
what <- oxford_comma(what)
}
if (inherits(arg, "AsIs")) {
format_arg <- identity
} else {
format_arg <- cli$format_arg
}

message <- sprintf(
"%s must be %s, not %s.",
cli$format_arg(arg),
format_arg(arg),
what,
obj_type_friendly(x, value = show_value)
)
Expand Down
Loading
Loading