Skip to content

Commit 116d5be

Browse files
committed
Minimal amount of work to deprecate lazyeval dplyr
1 parent 82eedad commit 116d5be

File tree

4 files changed

+521
-643
lines changed

4 files changed

+521
-643
lines changed

R/deprec-lazyeval.R

Lines changed: 19 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,12 @@
2525
#' @keywords internal
2626
NULL
2727

28-
lazy_deprec <- function(
29-
fun,
30-
hint = TRUE,
31-
env = caller_env(),
32-
user_env = caller_env(2)
33-
) {
34-
lifecycle::deprecate_warn(
28+
lazy_deprec <- function(fun, hint = TRUE) {
29+
lifecycle::deprecate_stop(
3530
when = "0.7.0",
3631
what = paste0(fun, "_()"),
3732
with = paste0(fun, "()"),
38-
details = if (hint) "See vignette('programming') for more help",
39-
env = env,
40-
user_env = user_env,
41-
always = TRUE
33+
details = if (hint) "See vignette('programming') for more help"
4234
)
4335
}
4436

@@ -301,11 +293,10 @@ rename_.grouped_df <- function(.data, ..., .dots = list()) {
301293
#' @export
302294
#' @rdname se-deprecated
303295
rename_vars_ <- function(vars, args) {
304-
lifecycle::deprecate_warn(
296+
lifecycle::deprecate_stop(
305297
"0.7.0",
306298
"rename_vars_()",
307-
"tidyselect::vars_rename()",
308-
always = TRUE
299+
"tidyselect::vars_rename()"
309300
)
310301
args <- compat_lazy_dots(args, caller_env())
311302
tidyselect::vars_rename(vars, !!!args)
@@ -333,11 +324,10 @@ select_.grouped_df <- function(.data, ..., .dots = list()) {
333324
#' include/exclude.
334325
#' @export
335326
select_vars_ <- function(vars, args, include = chr(), exclude = chr()) {
336-
lifecycle::deprecate_warn(
327+
lifecycle::deprecate_stop(
337328
"0.7.0",
338329
"select_vars_()",
339-
"tidyselect::vars_select()",
340-
always = TRUE
330+
"tidyselect::vars_select()"
341331
)
342332
args <- compat_lazy_dots(args, caller_env())
343333
tidyselect::vars_select(vars, !!!args, .include = include, .exclude = exclude)
@@ -391,91 +381,37 @@ summarize_ <- summarise_
391381
#' @keywords internal
392382
#' @export
393383
summarise_each <- function(tbl, funs, ...) {
394-
summarise_each_impl(tbl, funs, enquos(...), "summarise_each")
384+
summarise_each_impl("summarise_each")
395385
}
396386
#' @export
397387
#' @rdname summarise_each
398388
summarise_each_ <- function(tbl, funs, vars) {
399-
summarise_each_impl(tbl, funs, vars, "summarise_each_")
389+
summarise_each_impl("summarise_each_")
400390
}
401-
summarise_each_impl <- function(
402-
tbl,
403-
funs,
404-
vars,
405-
name,
406-
env = caller_env(),
407-
user_env = caller_env(2)
408-
) {
409-
what <- paste0(name, "()")
410-
411-
lifecycle::deprecate_warn(
391+
summarise_each_impl <- function(name) {
392+
lifecycle::deprecate_stop(
412393
when = "0.7.0",
413-
what = what,
414-
with = "across()",
415-
always = TRUE,
416-
env = env,
417-
user_env = user_env
394+
what = paste0(name, "()"),
395+
with = "across()"
418396
)
419-
420-
if (is_empty(vars)) {
421-
vars <- tbl_nongroup_vars(tbl)
422-
} else {
423-
vars <- compat_lazy_dots(vars, user_env)
424-
vars <- tidyselect::vars_select(tbl_nongroup_vars(tbl), !!!vars)
425-
if (length(vars) == 1 && names(vars) == as_string(vars)) {
426-
vars <- unname(vars)
427-
}
428-
}
429-
if (is_character(funs)) {
430-
funs <- funs_(funs)
431-
}
432-
funs <- manip_at(tbl, vars, funs, enquo(funs), user_env, .caller = name)
433-
summarise(tbl, !!!funs)
434397
}
435398

436399
#' @export
437400
#' @rdname summarise_each
438401
mutate_each <- function(tbl, funs, ...) {
439-
if (is_character(funs)) {
440-
funs <- funs_(funs)
441-
}
442-
mutate_each_impl(tbl, funs, enquos(...), "mutate_each")
402+
mutate_each_impl("mutate_each")
443403
}
444404
#' @export
445405
#' @rdname summarise_each
446406
mutate_each_ <- function(tbl, funs, vars) {
447-
mutate_each_impl(tbl, funs, vars, "mutate_each_")
407+
mutate_each_impl("mutate_each_")
448408
}
449-
mutate_each_impl <- function(
450-
tbl,
451-
funs,
452-
vars,
453-
name,
454-
env = caller_env(),
455-
user_env = caller_env(2)
456-
) {
457-
what <- paste0(name, "()")
458-
459-
lifecycle::deprecate_warn(
409+
mutate_each_impl <- function(name) {
410+
lifecycle::deprecate_stop(
460411
when = "0.7.0",
461-
what = what,
462-
with = "across()",
463-
always = TRUE,
464-
env = env,
465-
user_env = user_env
412+
what = paste0(name, "()"),
413+
with = "across()"
466414
)
467-
468-
if (is_empty(vars)) {
469-
vars <- tbl_nongroup_vars(tbl)
470-
} else {
471-
vars <- compat_lazy_dots(vars, user_env)
472-
vars <- tidyselect::vars_select(tbl_nongroup_vars(tbl), !!!vars)
473-
if (length(vars) == 1 && names(vars) == as_string(vars)) {
474-
vars <- unname(vars)
475-
}
476-
}
477-
funs <- manip_at(tbl, vars, funs, enquo(funs), user_env, .caller = name)
478-
mutate(tbl, !!!funs)
479415
}
480416

481417
#' @rdname summarise_each

tests/testthat/_snaps/deprec-lazyeval.md

Lines changed: 0 additions & 58 deletions
This file was deleted.

tests/testthat/test-deprec-funs.R

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,25 +95,25 @@ test_that("can enfun() purrr-style lambdas", {
9595
expect_type(res[[1]], "closure")
9696
})
9797

98-
test_that("funs_ works", {
99-
withr::local_options(lifecycle_verbosity = "quiet")
100-
101-
expect_equal(
102-
funs(mean),
103-
funs_(list(~mean))
104-
)
105-
106-
expect_equal(
107-
funs_(list("mean")),
108-
funs_(list(`environment<-`(~mean, baseenv()))),
109-
ignore_formula_env = TRUE
110-
)
111-
112-
expect_equal(
113-
funs(mean(.)),
114-
funs_(list(~ mean(.)))
115-
)
116-
})
98+
# test_that("funs_ works", {
99+
# withr::local_options(lifecycle_verbosity = "quiet")
100+
#
101+
# expect_equal(
102+
# funs(mean),
103+
# funs_(list(~mean))
104+
# )
105+
#
106+
# expect_equal(
107+
# funs_(list("mean")),
108+
# funs_(list(`environment<-`(~mean, baseenv()))),
109+
# ignore_formula_env = TRUE
110+
# )
111+
#
112+
# expect_equal(
113+
# funs(mean(.)),
114+
# funs_(list(~ mean(.)))
115+
# )
116+
# })
117117

118118
test_that("as_fun_list() auto names chr vectors (4307)", {
119119
df <- data.frame(x = 1:10)

0 commit comments

Comments
 (0)