diff --git a/NAMESPACE b/NAMESPACE index adc3e099..e20ecc71 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -84,15 +84,15 @@ export(vroom_progress) export(vroom_str) export(vroom_write) export(vroom_write_lines) +import(rlang) importFrom(bit64,integer64) importFrom(crayon,blue) importFrom(crayon,bold) -importFrom(crayon,col_nchar) importFrom(crayon,cyan) importFrom(crayon,green) importFrom(crayon,reset) importFrom(crayon,silver) -importFrom(glue,double_quote) +importFrom(glue,glue) importFrom(lifecycle,deprecate_warn) importFrom(lifecycle,deprecated) importFrom(methods,setOldClass) diff --git a/R/col_types.R b/R/col_types.R index c7796f46..6fd94d47 100644 --- a/R/col_types.R +++ b/R/col_types.R @@ -59,7 +59,7 @@ #' t3$cols <- c(t1$cols, t2$cols) #' t3 cols <- function(..., .default = col_guess(), .delim = NULL) { - col_types <- rlang::list2(...) + col_types <- list2(...) is_character <- vapply(col_types, is.character, logical(1)) col_types[is_character] <- lapply(col_types[is_character], col_concise) @@ -199,7 +199,7 @@ format.col_spec <- function(x, n = Inf, condense = NULL, colour = crayon::has_co delim <- x$delim if (!is.null(delim) && nzchar(delim)) { - delim <- paste0('.delim = ', double_quote(delim), '') + delim <- paste0('.delim = ', glue::double_quote(delim), '') } cols_args <- c( @@ -263,11 +263,11 @@ colourise_cols <- function(cols, colourise = crayon::has_color()) { col_double = , col_integer = , col_big_integer = , - col_number = crayon::green(cols[[i]]), + col_number = green(cols[[i]]), col_date = , col_datetime = , - col_time = crayon::blue(cols[[i]]) + col_time = blue(cols[[i]]) ) } cols @@ -346,8 +346,8 @@ col_concise <- function(x) { } vroom_enquo <- function(x) { - if (rlang::quo_is_call(x, "c") || rlang::quo_is_call(x, "list")) { - return(rlang::as_quosures(rlang::get_expr(x)[-1], rlang::get_env(x))) + if (quo_is_call(x, "c") || quo_is_call(x, "list")) { + return(as_quosures(get_expr(x)[-1], get_env(x))) } x } @@ -359,7 +359,7 @@ vroom_select <- function(x, col_select, id) { is_null <- vapply(x, is.null, logical(1)) x[is_null] <- NULL # reorder and rename columns - if (inherits(col_select, "quosures") || !rlang::quo_is_null(col_select)) { + if (inherits(col_select, "quosures") || !quo_is_null(col_select)) { if (inherits(col_select, "quosures")) { vars <- tidyselect::vars_select(c(names(spec(x)$cols), id), !!!col_select) } else { @@ -417,7 +417,7 @@ col_types_standardise <- function(spec, num_cols, col_names, col_select, name_re bad_types <- !(type_names %in% col_names) if (any(bad_types)) { - rlang::warn(paste0("The following named parsers don't match the column names: ", + warn(paste0("The following named parsers don't match the column names: ", paste0(type_names[bad_types], collapse = ", ")), class = "vroom_mismatched_column_name") spec$cols <- spec$cols[!bad_types] type_names <- type_names[!bad_types] @@ -433,7 +433,7 @@ col_types_standardise <- function(spec, num_cols, col_names, col_select, name_re spec$cols <- spec$cols[col_names] } - if (inherits(col_select, "quosures") || !rlang::quo_is_null(col_select)) { + if (inherits(col_select, "quosures") || !quo_is_null(col_select)) { if (inherits(col_select, "quosures")) { to_keep <- names(spec$cols) %in% tidyselect::vars_select(names(spec$cols), !!!col_select, .strict = FALSE) } else { @@ -535,8 +535,6 @@ collector_value.collector_time <- function(x, ...) { hms::hms() } #' @export collector_value.collector_guess <- function(x, ...) { character() } -#' @importFrom crayon silver -#' @importFrom glue double_quote #' @export summary.col_spec <- function(object, width = getOption("width"), locale = default_locale(), ...) { if (length(object$cols) == 0) { @@ -571,7 +569,7 @@ summary.col_spec <- function(object, width = getOption("width"), locale = defaul entries = glue::glue("{format(types)} {counts}: {columns}"), ' - {if (nzchar(delim)) paste(bold("Delimiter:"), double_quote(delim)) else ""} + {if (nzchar(delim)) paste(bold("Delimiter:"), glue::double_quote(delim)) else ""} {entries*} @@ -616,10 +614,10 @@ color_type <- function(type) { lgl = crayon::yellow(type), dbl = , int = , - num = crayon::green(type), + num = green(type), date = , dttm = , - time = crayon::blue(type), + time = blue(type), "???" = type ) } diff --git a/R/generator.R b/R/generator.R index bbb2f2fb..a7c44f45 100644 --- a/R/generator.R +++ b/R/generator.R @@ -162,7 +162,7 @@ gen_tbl <- function(rows, cols = NULL, col_types = NULL, locale = default_locale nms <- make_names(names(spec$cols), cols) - specs <- col_types_standardise(spec, length(nms), nms, vroom_enquo(rlang::quo(NULL)), "unique") + specs <- col_types_standardise(spec, length(nms), nms, vroom_enquo(quo(NULL)), "unique") res <- vector("list", cols) for (i in seq_len(cols)) { type <- sub("collector_", "", class(specs$cols[[i]])[[1]]) diff --git a/R/path.R b/R/path.R index 673b4d07..167b11f3 100644 --- a/R/path.R +++ b/R/path.R @@ -21,7 +21,7 @@ reencode_file <- function(path, encoding) { } # These functions adapted from https://github.com/tidyverse/readr/blob/192cb1ca5c445e359f153d2259391e6d324fd0a2/R/source.R -standardise_path <- function(path, user_env = rlang::caller_env(2)) { +standardise_path <- function(path, user_env = caller_env(2)) { if (is.raw(path)) { return(list(rawConnection(path, "rb"))) } @@ -80,7 +80,7 @@ standardise_one_path <- function (path, write = FALSE) { if (requireNamespace("curl", quietly = TRUE)) { con <- curl::curl(path) } else { - rlang::inform("`curl` package not installed, falling back to using `url()`") + inform("`curl` package not installed, falling back to using `url()`") con <- url(path) } ext <- tolower(tools::file_ext(path)) @@ -109,7 +109,7 @@ standardise_one_path <- function (path, write = FALSE) { path <- check_path(path) } - if (rlang::is_installed("archive")) { + if (is_installed("archive")) { formats <- archive_formats(p$extension) extension <- p$extension while(is.null(formats) && nzchar(extension)) { @@ -247,7 +247,7 @@ zipfile <- function(path, open = "r") { file <- files$Name[[1]] if (nrow(files) > 1) { - rlang::inform(paste0("Multiple files in zip: reading '", file, "'")) + inform(paste0("Multiple files in zip: reading '", file, "'")) } unz(path, file, open = open) diff --git a/R/vroom-package.R b/R/vroom-package.R index 90be3c30..218a6d3f 100644 --- a/R/vroom-package.R +++ b/R/vroom-package.R @@ -1,8 +1,18 @@ #' @keywords internal #' @aliases vroom-package +#' @useDynLib vroom, .registration = TRUE "_PACKAGE" ## usethis namespace: start +#' @import rlang +#' @importFrom bit64 integer64 +#' @importFrom crayon blue +#' @importFrom crayon bold +#' @importFrom crayon cyan +#' @importFrom crayon green +#' @importFrom crayon reset +#' @importFrom crayon silver +#' @importFrom glue glue #' @importFrom lifecycle deprecate_warn #' @importFrom lifecycle deprecated ## usethis namespace: end diff --git a/R/vroom.R b/R/vroom.R index 31d35b08..780da745 100644 --- a/R/vroom.R +++ b/R/vroom.R @@ -1,7 +1,3 @@ -#' @useDynLib vroom, .registration = TRUE -#' @importFrom bit64 integer64 -NULL - #' Read a delimited file into a tibble #' #' @param file Either a path to a file, a connection, or literal data (either a @@ -217,7 +213,7 @@ vroom <- function( delim <- "\x01" } - if (!rlang::is_missing(altrep_opts)) { + if (!is_missing(altrep_opts)) { deprecate_warn("1.1.0", "vroom(altrep_opts = )", "vroom(altrep = )") altrep <- altrep_opts } @@ -249,7 +245,7 @@ vroom <- function( Sys.setenv("RSTUDIO" = "1") } - col_select <- vroom_enquo(rlang::enquo(col_select)) + col_select <- vroom_enquo(enquo(col_select)) has_col_types <- !is.null(col_types) @@ -331,7 +327,7 @@ make_names <- function(x, len) { #' vroom_progress() vroom_progress <- function() { env_to_logical("VROOM_SHOW_PROGRESS", TRUE) && - rlang::is_interactive() && + is_interactive() && # some analysis re: rstudio.notebook.executing can be found in: # https://github.com/r-lib/rlang/issues/1031 # TL;DR it's not consulted by is_interactive(), but probably should be @@ -339,7 +335,6 @@ vroom_progress <- function() { !isTRUE(getOption("rstudio.notebook.executing")) } -#' @importFrom crayon blue cyan green bold reset col_nchar pb_file_format <- function(filename) { # Workaround RStudio bug https://github.com/rstudio/rstudio/issues/4777 @@ -349,7 +344,7 @@ pb_file_format <- function(filename) { } pb_width <- function(format) { - ansii_chars <- nchar(format) - col_nchar(format) + ansii_chars <- nchar(format) - crayon::col_nchar(format) getOption("width", 80L) + ansii_chars } diff --git a/R/vroom_fwf.R b/R/vroom_fwf.R index 15853a86..c60b27a4 100644 --- a/R/vroom_fwf.R +++ b/R/vroom_fwf.R @@ -40,8 +40,8 @@ vroom_fwf <- function(file, verify_fwf_positions(col_positions) - if (!rlang::is_missing(altrep_opts)) { - lifecycle::deprecate_warn("1.1.0", "vroom_fwf(altrep_opts = )", "vroom_fwf(altrep = )") + if (!is_missing(altrep_opts)) { + deprecate_warn("1.1.0", "vroom_fwf(altrep_opts = )", "vroom_fwf(altrep = )") altrep <- altrep_opts } @@ -66,7 +66,7 @@ vroom_fwf <- function(file, guess_max <- -1 } - col_select <- vroom_enquo(rlang::enquo(col_select)) + col_select <- vroom_enquo(enquo(col_select)) has_col_types <- !is.null(col_types) diff --git a/R/vroom_lines.R b/R/vroom_lines.R index efb4c96b..0d08d59b 100644 --- a/R/vroom_lines.R +++ b/R/vroom_lines.R @@ -18,8 +18,8 @@ vroom_lines <- function(file, n_max = Inf, skip = 0, altrep_opts = deprecated(), num_threads = vroom_threads(), progress = vroom_progress()) { - if (!rlang::is_missing(altrep_opts)) { - lifecycle::deprecate_warn("1.1.0", "vroom_lines(altrep_opts = )", "vroom_lines(altrep = )") + if (!is_missing(altrep_opts)) { + deprecate_warn("1.1.0", "vroom_lines(altrep_opts = )", "vroom_lines(altrep = )") altrep <- altrep_opts } @@ -38,7 +38,7 @@ vroom_lines <- function(file, n_max = Inf, skip = 0, return(character()) } - col_select <- rlang::quo(NULL) + col_select <- quo(NULL) # delim = "\1" sets the delimiter to be start of header, which should never # appear in modern text. This essentially means the only record breaks will diff --git a/tests/testthat/test-problems.R b/tests/testthat/test-problems.R index 8d459476..6ddd9294 100644 --- a/tests/testthat/test-problems.R +++ b/tests/testthat/test-problems.R @@ -172,7 +172,7 @@ test_that("can promote vroom parse warning to error", { withCallingHandlers( expr = make_warning(), vroom_parse_issue = function(cnd) { - rlang::abort("oh no") + abort("oh no") } ) )