Skip to content

Commit d04bb0c

Browse files
bms63Copilotmanciniedoardobundfussr
authored
[skip vbump] Closes #534 #532 #529 Release 1.4...Release the 🦑 !!! (#535)
* docs: #532 short blurb on experimental fcns * Move deprecated functions to Phase 3 and add Phase 1 deprecations (#536) * Initial plan * Move deprecated functions to Phase 3 and add Phase 1 deprecations - Updated arg_name(), enumerate(), what_is_it(), and friendly_type_of() to Phase 3 (error) using deprecate_stop() - Added Phase 1 deprecation messages to %or% and valid_time_units() using deprecate_inform() - Updated documentation with lifecycle badges and deprecated keywords/families - Updated unit tests to check for deprecation errors (Phase 3) and messages (Phase 1) - Updated NEWS.md with deprecation phase changes Co-authored-by: bms63 <10111024+bms63@users.noreply.github.com> * tests: #529 new snaps who dis? * docs: #529 regen docs; tests: reorg tests and snaps --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bms63 <10111024+bms63@users.noreply.github.com> Co-authored-by: Ben Straub <ben.x.straub@gsk.com> * chore: #534 cleaning up spelling * #534 fix lints and roxygen * #534: update man * #534: update NEWS * chore: #534 aligning packages deps in admiraldev and admiral * remove: #534 unused fcn * docs: #486 remove CODEOWNERS --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: bms63 <10111024+bms63@users.noreply.github.com> Co-authored-by: Edoardo Mancini <edoardo.mancini@roche.com> Co-authored-by: Stefan Bundfuss <stefan.bundfuss@roche.com>
1 parent 7ff0baa commit d04bb0c

32 files changed

+249
-541
lines changed

‎.github/CODEOWNERS‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎DESCRIPTION‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ BugReports: https://github.com/pharmaverse/admiraldev/issues
3434
Depends:
3535
R (>= 4.1)
3636
Imports:
37-
cli (>= 3.0.0),
37+
cli (>= 3.6.2),
3838
dplyr (>= 1.1.1),
3939
glue (>= 1.6.0),
4040
lifecycle (>= 0.1.0),
@@ -44,7 +44,7 @@ Imports:
4444
roxygen2 (>= 7.0.0),
4545
stringr (>= 1.4.0),
4646
tidyr (>= 1.0.2),
47-
tidyselect (>= 1.0.0),
47+
tidyselect (>= 1.1.0),
4848
withr
4949
Suggests:
5050
diffdf,

‎NEWS.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,25 @@ has been updated from 1.0.5 to 1.1.1. (#530)
2525
- The following function arguments are entering the next phase of the [deprecation process](https://pharmaverse.github.io/admiraldev/articles/programming_strategy.html#deprecation): (#2487) (#2595)
2626

2727
**Phase 1 (message)**
28+
29+
- `%or%` - Please get in touch if you are using this function!
30+
- `valid_time_units()` - Please get in touch if you are using this function!
2831

2932
**Phase 2 (warning)**
3033

34+
No functions or arguments in this Phase
35+
3136
**Phase 3 (error)**
3237

38+
- `arg_name()` - Use `rlang::caller_arg()` instead
39+
- `enumerate()` - Use `cli` functionality instead, e.g., `cli::cli_abort('{.val {letters[1:3]}}')`
40+
- `what_is_it()` - Use `cli` functionality instead, e.g., `cli::cli_abort('{.obj_type_friendly {letters}}')`
41+
- `friendly_type_of()` - Use `cli` functionality instead, e.g., `cli::cli_abort('{.obj_type_friendly {letters}}')`
42+
3343
**Phase 4 (removed)**
3444

45+
No functions or arguments in this Phase
46+
3547
## Documentation
3648

3749
- Added the "Ask AI" widget to the the bottom right of each page. It enables users to ask questions about `{admiraldev}` and the
@@ -48,6 +60,8 @@ and to improve its formatting. (#365)
4860
full title of all linked resources to ensure that resources can be found if links
4961
become defunct or broken. (#463)
5062

63+
- Removed use of CODEOWNERS and discussion in Pull Request Guidance (#486)
64+
5165
## Various
5266

5367
- Added various unit tests to improve the test coverage of `{admiraldev}`. (#524)

‎R/compat_friendly_type.R‎

Lines changed: 8 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#' Return English-friendly messaging for object-types
22
#'
3+
#' @description
4+
#' `r lifecycle::badge("deprecated")`
5+
#'
6+
#' This function is *deprecated*, please use `cli` functionality instead.
7+
#'
38
#' @param x Any R object.
49
#' @param value Whether to describe the value of `x`.
510
#' @param length Whether to mention the length of vectors and lists.
@@ -14,174 +19,13 @@
1419
#' @return A string describing the type. Starts with an indefinite
1520
#' article, e.g. "an integer vector".
1621
#'
17-
#' @keywords dev_utility
18-
#' @family dev_utility
22+
#' @keywords deprecated
23+
#' @family deprecated
1924
friendly_type_of <- function(x, value = TRUE, length = FALSE) { # nolint
20-
lifecycle::deprecate_soft(
25+
lifecycle::deprecate_stop(
2126
when = "1.1.0",
2227
what = "admiraldev::friendly_type_of()",
2328
details = "This function was primarily used in error messaging, and can be replaced
2429
with 'cli' functionality: `cli::cli_abort('{.obj_type_friendly {letters}}')`."
2530
)
26-
27-
if (rlang::is_missing(x)) {
28-
return("absent")
29-
}
30-
31-
if (is.object(x)) {
32-
if (inherits(x, "quosure")) {
33-
type <- "quosure"
34-
} else {
35-
type <- paste(class(x), collapse = "/")
36-
}
37-
return(sprintf("a <%s> object", type))
38-
}
39-
40-
if (!rlang::is_vector(x)) {
41-
return(.rlang_as_friendly_type(typeof(x)))
42-
}
43-
44-
n_dim <- length(dim(x))
45-
46-
if (value && !n_dim) {
47-
if (rlang::is_na(x)) {
48-
return(switch(typeof(x),
49-
logical = "`NA`",
50-
integer = "an integer `NA`",
51-
double = "a numeric `NA`",
52-
complex = "a complex `NA`",
53-
character = "a character `NA`",
54-
.rlang_stop_unexpected_typeof(x)
55-
))
56-
}
57-
if (length(x) == 1 && !rlang::is_list(x)) {
58-
return(switch(typeof(x),
59-
logical = if (x) "`TRUE`" else "`FALSE`",
60-
integer = "an integer",
61-
double = "a number",
62-
complex = "a complex number",
63-
character = if (nzchar(x)) "a string" else "`\"\"`",
64-
raw = "a raw value",
65-
.rlang_stop_unexpected_typeof(x)
66-
))
67-
}
68-
if (length(x) == 0) {
69-
return(switch(typeof(x),
70-
logical = "an empty logical vector",
71-
integer = "an empty integer vector",
72-
double = "an empty numeric vector",
73-
complex = "an empty complex vector",
74-
character = "an empty character vector",
75-
raw = "an empty raw vector",
76-
list = "an empty list",
77-
.rlang_stop_unexpected_typeof(x)
78-
))
79-
}
80-
}
81-
82-
type <- .rlang_as_friendly_vector_type(typeof(x), n_dim)
83-
84-
if (length && !n_dim) {
85-
type <- paste0(type, sprintf(" of length %s", length(x)))
86-
}
87-
88-
type
89-
}
90-
91-
# Used in building `friendly_type_of()` above
92-
.rlang_as_friendly_vector_type <- function(type, n_dim) {
93-
if (type == "list") {
94-
if (n_dim < 2) {
95-
return("a list")
96-
} else if (n_dim == 2) {
97-
return("a list matrix")
98-
} else {
99-
return("a list array")
100-
}
101-
}
102-
103-
type <- switch(type,
104-
logical = "a logical %s",
105-
integer = "an integer %s",
106-
numeric = , # nolint
107-
double = "a double %s",
108-
complex = "a complex %s",
109-
character = "a character %s",
110-
raw = "a raw %s",
111-
type = paste0("a ", type, " %s")
112-
)
113-
114-
if (n_dim < 2) {
115-
kind <- "vector"
116-
} else if (n_dim == 2) {
117-
kind <- "matrix"
118-
} else {
119-
kind <- "array"
120-
}
121-
sprintf(type, kind)
122-
}
123-
124-
# Used in building `friendly_type_of()` above
125-
.rlang_as_friendly_type <- function(type) {
126-
switch(type,
127-
list = "a list",
128-
NULL = "NULL",
129-
environment = "an environment",
130-
externalptr = "a pointer",
131-
weakref = "a weak reference",
132-
S4 = "an S4 object",
133-
name = , # nolint
134-
symbol = "a symbol",
135-
language = "a call",
136-
pairlist = "a pairlist node",
137-
expression = "an expression vector",
138-
char = "an internal string",
139-
promise = "an internal promise",
140-
... = "an internal dots object",
141-
any = "an internal `any` object",
142-
bytecode = "an internal bytecode object",
143-
primitive = , # nolint
144-
builtin = , # nolint
145-
special = "a primitive function",
146-
closure = "a function",
147-
type
148-
)
149-
}
150-
151-
# Used in building `friendly_type_of()` above
152-
.rlang_stop_unexpected_typeof <- function(x, call = rlang::caller_env()) {
153-
rlang::abort(
154-
sprintf("Unexpected type <%s>.", typeof(x)),
155-
call = call
156-
)
157-
}
158-
159-
#' @param x The object type which does not conform to `what`. Its
160-
#' `friendly_type_of()` is taken and mentioned in the error message.
161-
#' @param what The friendly expected type.
162-
#' @param ... Arguments passed to [abort()].
163-
#' @inheritParams args_error_context
164-
#' @noRd
165-
stop_input_type <- function(x,
166-
what,
167-
...,
168-
arg = rlang::caller_arg(x),
169-
call = rlang::caller_env()) {
170-
# From compat-cli.R
171-
format_arg <- rlang::env_get(
172-
nm = "format_arg",
173-
last = topenv(),
174-
default = NULL
175-
)
176-
if (!is.function(format_arg)) {
177-
format_arg <- function(x) sprintf("`%s`", x)
178-
}
179-
180-
msg <- sprintf(
181-
"%s must be %s, not %s.",
182-
format_arg(arg),
183-
what,
184-
friendly_type_of(x)
185-
)
186-
rlang::abort(msg, ..., call = call)
18731
}

‎R/dev_utilities.R‎

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,36 +34,26 @@ convert_dtm_to_dtc <- function(dtm) {
3434

3535
#' Extract Argument Name from an Expression
3636
#'
37+
#' @description
38+
#' `r lifecycle::badge("deprecated")`
39+
#'
40+
#' This function is *deprecated*, please use `rlang::caller_arg()` instead.
41+
#'
3742
#' @param expr An expression created inside a function using `substitute()`
3843
#'
3944
#'
4045
#' @return `character` vector
4146
#'
42-
#' @keywords dev_utility
43-
#' @family dev_utility
47+
#' @keywords deprecated
48+
#' @family deprecated
4449
#'
4550
#' @export
4651
arg_name <- function(expr) { # nolint
47-
lifecycle::deprecate_soft(
52+
lifecycle::deprecate_stop(
4853
when = "1.1.0",
4954
what = "admiraldev::arg_name()",
50-
details = "This function was primarily used in error messaging, and can be
51-
replaced with `assert_*(x, arg_name = rlang::caller_arg(x))`"
55+
with = "rlang::caller_arg()"
5256
)
53-
54-
if (length(expr) == 1L && is.symbol(expr)) {
55-
deparse(expr)
56-
} else if (length(expr) == 2L &&
57-
(expr[[1L]] == quote(enexpr) || expr[[1L]] == quote(rlang::enexpr)) &&
58-
is.symbol(expr[[2L]])) {
59-
deparse(expr[[2L]])
60-
} else if (is.call(expr) && length(expr) >= 2 && is.symbol(expr[[2]])) {
61-
deparse(expr[[2L]])
62-
} else if (is.call(expr) && length(expr) >= 2 && is.call(expr[[2]])) {
63-
arg_name(expr[[2L]])
64-
} else {
65-
abort(paste0("Could not extract argument name from `", deparse(expr), "`"))
66-
}
6757
}
6858

6959
#' Extract All Symbols from a List of Expressions
@@ -101,6 +91,11 @@ extract_vars <- function(x, side = "lhs") {
10191

10292
#' Or
10393
#'
94+
#' @description
95+
#' `r lifecycle::badge("deprecated")`
96+
#'
97+
#' This function is *deprecated*. Please get in touch if you are using this function!
98+
#'
10499
#' @param lhs Any valid R expression
105100
#' @param rhs Any valid R expression
106101
#'
@@ -113,23 +108,48 @@ extract_vars <- function(x, side = "lhs") {
113108
#'
114109
#' @export
115110
#'
116-
#' @keywords dev_utility
117-
#' @family dev_utility
111+
#' @keywords deprecated
112+
#' @family deprecated
118113
`%or%` <- function(lhs, rhs) {
114+
deprecate_inform(
115+
when = "1.4.0",
116+
what = "admiraldev::`%or%`()",
117+
details = c(
118+
x = "This message will turn into a warning at the beginning of 2027.",
119+
i = "See admiral's deprecation guidance:
120+
https://pharmaverse.github.io/admiraldev/dev/articles/programming_strategy.html#deprecation", # nolint
121+
i = "Please get in touch if you are using this function!"
122+
)
123+
)
119124
tryCatch(lhs, error = function(e) rhs)
120125
}
121126

122127
#' Valid Time Units
123128
#'
129+
#' @description
130+
#' `r lifecycle::badge("deprecated")`
131+
#'
132+
#' This function is *deprecated*. Please get in touch if you are using this function!
133+
#'
124134
#' Contains the acceptable character vector of valid time units
125135
#'
126136
#' @return A `character` vector of valid time units
127137
#'
128138
#' @export
129139
#'
130-
#' @keywords dev_utility
131-
#' @family dev_utility
140+
#' @keywords deprecated
141+
#' @family deprecated
132142
valid_time_units <- function() {
143+
deprecate_inform(
144+
when = "1.4.0",
145+
what = "admiraldev::valid_time_units()",
146+
details = c(
147+
x = "This message will turn into a warning at the beginning of 2027.",
148+
i = "See admiral's deprecation guidance:
149+
https://pharmaverse.github.io/admiraldev/dev/articles/programming_strategy.html#deprecation", # nolint
150+
i = "Please get in touch if you are using this function!"
151+
)
152+
)
133153
c("years", "months", "days", "hours", "minutes", "seconds")
134154
}
135155

0 commit comments

Comments
 (0)