Skip to content

Commit a041d39

Browse files
committed
Update embedded pkgdepends
For r-lib/pkgdepends@634661a
1 parent c365d55 commit a041d39

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1133
-442
lines changed

src/library/pkgdepends/DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Config/usethis/last-upkeep: 2025-05-05
3737
Encoding: UTF-8
3838
RoxygenNote: 7.3.2.9000
3939
NeedsCompilation: yes
40-
Packaged: 2026-03-10 08:02:30 UTC; gaborcsardi
40+
Packaged: 2026-03-19 17:25:38 UTC; gaborcsardi
4141
Author: Gábor Csárdi [aut, cre],
4242
Posit Software, PBC [cph, fnd] (ROR: <https://ror.org/03wc8by49>)
4343
Maintainer: Gábor Csárdi <csardi.gabor@gmail.com>

src/library/pkgdepends/R/aaa-rstudio-detect.R

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@ rstudio <- local({
5151
}
5252

5353
# Cached?
54-
if (clear_cache) data <<- NULL
55-
if (!is.null(data)) return(get_caps(data))
54+
if (clear_cache) {
55+
data <<- NULL
56+
}
57+
if (!is.null(data)) {
58+
return(get_caps(data))
59+
}
5660

5761
if (
5862
(rspid <- Sys.getenv("RSTUDIO_SESSION_PID")) != "" &&
@@ -86,7 +90,9 @@ rstudio <- local({
8690
pane <- Sys.getenv("RSTUDIO_CHILD_PROCESS_PANE")
8791

8892
# this should not happen, but be defensive and fall back
89-
if (pane == "") return(detect_old(clear_cache))
93+
if (pane == "") {
94+
return(detect_old(clear_cache))
95+
}
9096

9197
# direct subprocess
9298
new$type <- if (rspid == parentpid) {
@@ -175,7 +181,9 @@ rstudio <- local({
175181
}
176182

177183
installing <- Sys.getenv("R_PACKAGE_DIR", "")
178-
if (cache && installing == "") data <<- new
184+
if (cache && installing == "") {
185+
data <<- new
186+
}
179187

180188
get_caps(new)
181189
}

src/library/pkgdepends/R/assertions.R

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,37 @@ is_character <- function(x) {
1818
}
1919
}
2020

21+
is_non_empty_character <- function(x) {
22+
if (!is.character(x)) {
23+
structure(
24+
FALSE,
25+
msg = "{.arg {(.arg)}} must be a non-empty character vector without {.code NA},
26+
but it is {.type {x}}",
27+
env = environment()
28+
)
29+
} else if (anyNA(x)) {
30+
structure(
31+
FALSE,
32+
msg = "{.arg {(.arg)}} must be a non-empty character vector without {.code NA},
33+
but it has {sum(is.na(x))} {.code NA} value{?s}.",
34+
env = environment()
35+
)
36+
} else if (length(x) == 0) {
37+
structure(
38+
FALSE,
39+
msg = "{.arg {(.arg)}} must be a non-empty character vector without {.code NA},
40+
but it is empty.",
41+
env = environment()
42+
)
43+
} else {
44+
TRUE
45+
}
46+
}
47+
2148
is_string <- function(x) {
22-
if (is.character(x) && length(x) == 1 && !is.na(x)) return(TRUE)
49+
if (is.character(x) && length(x) == 1 && !is.na(x)) {
50+
return(TRUE)
51+
}
2352
if (is.character(x) && length(x) == 1 && is.na(x)) {
2453
structure(
2554
FALSE,
@@ -37,7 +66,9 @@ is_string <- function(x) {
3766
}
3867

3968
is_optional_string <- function(x) {
40-
if (is.null(x) || is_string(x)) return(TRUE)
69+
if (is.null(x) || is_string(x)) {
70+
return(TRUE)
71+
}
4172
structure(
4273
FALSE,
4374
msg = "{.arg {(.arg)}} must be a path (character scalar),
@@ -47,7 +78,9 @@ is_optional_string <- function(x) {
4778
}
4879

4980
is_flag <- function(x) {
50-
if (is.logical(x) && length(x) == 1 && !is.na(x)) return(TRUE)
81+
if (is.logical(x) && length(x) == 1 && !is.na(x)) {
82+
return(TRUE)
83+
}
5184
if (is.logical(x) && length(x) == 1 && is.na(x)) {
5285
structure(
5386
FALSE,
@@ -67,7 +100,9 @@ is_flag <- function(x) {
67100
## To be refined
68101

69102
is_path <- function(x) {
70-
if (is_string(x)) return(TRUE)
103+
if (is_string(x)) {
104+
return(TRUE)
105+
}
71106
structure(
72107
FALSE,
73108
msg = "{.arg {(.arg)}} must be a path (character scalar),
@@ -77,7 +112,9 @@ is_path <- function(x) {
77112
}
78113

79114
is_optional_path <- function(x) {
80-
if (is_optional_string(x)) return(TRUE)
115+
if (is_optional_string(x)) {
116+
return(TRUE)
117+
}
81118
structure(
82119
FALSE,
83120
msg = "{.arg {(.arg)}} must be a path (character scalar) or {.code NULL},
@@ -87,7 +124,9 @@ is_optional_path <- function(x) {
87124
}
88125

89126
all_named <- function(x) {
90-
if (length(names(x)) == length(x) && all(names(x) != "")) return(TRUE)
127+
if (length(names(x)) == length(x) && all(names(x) != "")) {
128+
return(TRUE)
129+
}
91130
structure(
92131
FALSE,
93132
msg = "All elements in {.arg {(.arg)}} must be named.",
@@ -202,7 +241,9 @@ is_r_version_list <- function(x) {
202241
}
203242

204243
is_difftime <- function(x) {
205-
if (inherits(x, "difftime")) return(TRUE)
244+
if (inherits(x, "difftime")) {
245+
return(TRUE)
246+
}
206247
structure(
207248
FALSE,
208249
msg = "{.arg {(.arg)}} must be a {.cls difftime} object, but it is

src/library/pkgdepends/R/assertthat.R

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ assert_that <- function(..., env = parent.frame(), msg = NULL) {
1111
}
1212
)
1313
check_result(res)
14-
if (res) next
14+
if (res) {
15+
next
16+
}
1517

1618
if (is.null(msg)) {
1719
msg <- get_message(res, assertion, env)
@@ -55,8 +57,12 @@ assert_error <- function(
5557
)
5658
)
5759

58-
if (length(.data)) cnd[names(.data)] <- .data
59-
if (length(class)) class(cnd) <- unique(c(.class, "assertError", class(cnd)))
60+
if (length(.data)) {
61+
cnd[names(.data)] <- .data
62+
}
63+
if (length(class)) {
64+
class(cnd) <- unique(c(.class, "assertError", class(cnd)))
65+
}
6066

6167
cnd
6268
}
@@ -90,7 +96,9 @@ get_message <- function(res, call, env = parent.frame()) {
9096
}
9197

9298
f <- eval(call[[1]], env)
93-
if (is.call(call) && !is.primitive(f)) call <- match.call(f, call)
99+
if (is.call(call) && !is.primitive(f)) {
100+
call <- match.call(f, call)
101+
}
94102
fname <- deparse(call[[1]])
95103

96104
base_fs[[fname]] %||% fail_default(call, env)
@@ -110,7 +118,9 @@ fail_default <- function(call, env) {
110118
}
111119

112120
has_attr <- function(x, which) {
113-
if (!is.null(attr(x, which, exact = TRUE))) return(TRUE)
121+
if (!is.null(attr(x, which, exact = TRUE))) {
122+
return(TRUE)
123+
}
114124
structure(
115125
FALSE,
116126
msg = "{.arg {(.arg)}} must have attribute {.code {which}}.",

src/library/pkgdepends/R/config.R

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@
9999
#' String or `NULL`. `NA` is not allowed. In environment variables the
100100
#' string `NULL` means an R `NULL` value.
101101
#'
102+
#' ## `character_or_null`
103+
#'
104+
#' Character vector or `NULL`. `NA` is not allowed. In environment variables
105+
#' the entries are separated by a semicolon.
106+
#'
102107
#' ## `character`
103108
#'
104109
#' Character vector without `NA` values. In environment variables the
@@ -117,7 +122,9 @@ config <- local({
117122
true <- function(...) TRUE
118123

119124
is_config_name <- function(name) {
120-
if (is_string(name)) return(TRUE)
125+
if (is_string(name)) {
126+
return(TRUE)
127+
}
121128
structure(
122129
FALSE,
123130
msg = c(
@@ -129,7 +136,9 @@ config <- local({
129136
}
130137

131138
is_config_check <- function(check) {
132-
if (is_string(check) || is.function(check) || is.null(check)) return(TRUE)
139+
if (is_string(check) || is.function(check) || is.null(check)) {
140+
return(TRUE)
141+
}
133142
structure(
134143
FALSE,
135144
msg = c(
@@ -153,6 +162,7 @@ config <- local({
153162
# Built-in types
154163
builtin_types <- c(
155164
"character",
165+
"character_or_null",
156166
"count",
157167
"custom",
158168
"flag",
@@ -163,6 +173,9 @@ config <- local({
163173
# Checks for builtin types
164174
builtin_checks <- list(
165175
character = function(x) is.character(x) && !anyNA(x),
176+
character_or_null = function(x) {
177+
(is.character(x) && !anyNA(x)) || is.null(x)
178+
},
166179
custom = function(x) true(x),
167180
flag = function(x) is_flag(x),
168181
string = function(x) is_string(x),
@@ -183,15 +196,22 @@ config <- local({
183196
},
184197
flag = function(x, name, ...) {
185198
x <- tolower(x)
186-
if (tolower(x) %in% c("yes", "true", "1", "on")) return(TRUE)
187-
if (tolower(x) %in% c("no", "false", "0", "off")) return(FALSE)
199+
if (tolower(x) %in% c("yes", "true", "1", "on")) {
200+
return(TRUE)
201+
}
202+
if (tolower(x) %in% c("no", "false", "0", "off")) {
203+
return(FALSE)
204+
}
188205
throw(pkg_error(
189206
"Invalid value for the {.envvar {name}} environment variable.",
190207
i = "It must be either {.code true} or {.code false}."
191208
))
192209
},
193210
string = function(x, ...) x,
194211
string_or_null = function(x, ...) if (identical(x, "NULL")) NULL else x,
212+
character_or_null = function(x, ...) {
213+
if (x %in% c("", "NULL")) NULL else strsplit(x, ";", fixed = TRUE)[[1]]
214+
},
195215
count = function(x, name, ...) {
196216
num <- suppressWarnings(as.numeric(num))
197217
if (is.na(num) || !is_count(num)) {
@@ -218,13 +238,17 @@ config <- local({
218238
rec <- env$data[[name]]
219239

220240
# was explicitly set?
221-
if (!is.null(rec$value)) return(list("set", rec$value))
241+
if (!is.null(rec$value)) {
242+
return(list("set", rec$value))
243+
}
222244

223245
# set via options()
224246
optname <- paste0(env$prefix, name)
225247
opt <- getOption(optname)
226248
if (!is.null(opt)) {
227-
if (!is.null(chk <- env$data[[name]]$check)) chk(opt)
249+
if (!is.null(chk <- env$data[[name]]$check)) {
250+
chk(opt)
251+
}
228252
return(list("option", opt))
229253
}
230254

@@ -365,11 +389,17 @@ config <- local({
365389
))
366390
}
367391

368-
if (is_string(check)) check <- env$checks[[check]]
392+
if (is_string(check)) {
393+
check <- env$checks[[check]]
394+
}
369395
check <- check %||% true
370-
if (!is.null(default) && !is.function(default)) check(default)
396+
if (!is.null(default) && !is.function(default)) {
397+
check(default)
398+
}
371399

372-
if (is_string(env_decode)) env_decode <- env$env_decode[[env_decode]]
400+
if (is_string(env_decode)) {
401+
env_decode <- env$env_decode[[env_decode]]
402+
}
373403
env_decode <- env_decode %||% identity
374404

375405
env$data[[name]] <- list(
@@ -454,7 +484,9 @@ config <- local({
454484
i = "See `$list()` for the list of all config entries."
455485
))
456486
}
457-
if (!is.null(chk <- env$data[[name]]$check)) chk(value)
487+
if (!is.null(chk <- env$data[[name]]$check)) {
488+
chk(value)
489+
}
458490
env$data[[name]]$value <- value
459491
invisible(env)
460492
}

src/library/pkgdepends/R/dep-utils.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ deps_from_desc <- function(deps, last) {
6767
parse_all_deps <- function(deps) {
6868
deps <- na.omit(deps)
6969
res <- do.call(rbind, parse_deps(deps, names(deps)))
70-
if (is.null(res)) res <- parse_deps("", "")[[1]]
70+
if (is.null(res)) {
71+
res <- parse_deps("", "")[[1]]
72+
}
7173
res$ref <- res$package
7274
res[, c("ref", setdiff(names(res), "ref"))]
7375
}

0 commit comments

Comments
 (0)