Skip to content

Commit 0b3c7a8

Browse files
committed
Address code review
1 parent 6b01e77 commit 0b3c7a8

2 files changed

Lines changed: 3 additions & 15 deletions

File tree

R/namespace.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,9 @@ import_from <- function(package, funs, expanded = FALSE) {
201201
)
202202
}
203203

204-
# Conflicting `@importAllFrom` directives are detected at document-time. An
205-
# error is thrown so the user has to resolve the conflict to build the package.
204+
# Conflicting `@importAllFrom` directives (either with another `@importAllFrom`
205+
# or a regular `@importFrom`) are detected at document-time. An error is thrown
206+
# so the user has to resolve the conflict to build the package.
206207
check_import_conflicts <- function(imports) {
207208
syms <- map(imports, \(x) strip_quotes(x$funs))
208209
imported <- data.frame(
@@ -222,7 +223,6 @@ check_import_conflicts <- function(imports) {
222223
# Re-exports aren't real conflicts: when several packages export the same
223224
# object (e.g. `%>%`), importing it from more than one is harmless.
224225
conflicts <- discard(conflicts, \(x) is_reexport(x$sym[[1]], unique(x$pkg)))
225-
226226
if (length(conflicts) == 0) {
227227
return(invisible())
228228
}
@@ -235,7 +235,6 @@ check_import_conflicts <- function(imports) {
235235
conflict <- conflicts[[1]]
236236
example_sym <- auto_quote(conflict$sym[[1]])
237237
example_pkg <- conflict$pkg[conflict$expanded][[1]]
238-
239238
cli::cli_abort(c(
240239
"Found {length(conflicts)} conflicting import{?s} from {.code @importAllFrom}.",
241240
set_names(bullets, rep("*", length(bullets))),

tests/testthat/test-namespace.R

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -434,17 +434,6 @@ test_that("import doesn't quote if comma present", {
434434
expect_equal(sort(out), "import(rlang, except = ':=')")
435435
})
436436

437-
test_that("@import never expands, even for an installed package", {
438-
out <- roc_proc_text(
439-
namespace_roclet(),
440-
"
441-
#' @import utils
442-
NULL"
443-
)
444-
445-
expect_equal(out, "import(utils)")
446-
})
447-
448437
test_that("@importAllFrom drops symbols excluded with a - prefix", {
449438
pkgload::load_all(test_path("testImports"), quiet = TRUE)
450439
withr::defer(pkgload::unload("testImports"))

0 commit comments

Comments
 (0)