diff --git a/NEWS.md b/NEWS.md index ba82882e..49b6e7de 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,8 @@ -# pins (development version) +# pins (development version to be released as 1.3.0) + +## Breaking changes + +* Changed the function signature of `pin_write()` so arguments like `type` and `title` must be passed by name and not position (#792). # pins 1.2.2 diff --git a/R/pin-read-write.R b/R/pin-read-write.R index a7a8c887..a7405c13 100644 --- a/R/pin-read-write.R +++ b/R/pin-read-write.R @@ -71,15 +71,19 @@ pin_read <- function(board, name, version = NULL, hash = NULL, ...) { #' @export pin_write <- function(board, x, name = NULL, + ..., type = NULL, title = NULL, description = NULL, metadata = NULL, versioned = NULL, tags = NULL, - ..., force_identical_write = FALSE) { check_board(board, "pin_write", "pin") + dots <- list2(...) + if (!missing(...) && (is.null(names(dots)) || names(dots)[[1]] == "")) { + cli::cli_abort('Arguments after the dots `...` must be named, like {.code type = "json"}.') + } if (is.null(name)) { name <- enexpr(x) diff --git a/man/pin_read.Rd b/man/pin_read.Rd index aa15768c..fdc80697 100644 --- a/man/pin_read.Rd +++ b/man/pin_read.Rd @@ -11,13 +11,13 @@ pin_write( board, x, name = NULL, + ..., type = NULL, title = NULL, description = NULL, metadata = NULL, versioned = NULL, tags = NULL, - ..., force_identical_write = FALSE ) } diff --git a/tests/testthat/_snaps/pin-read-write.md b/tests/testthat/_snaps/pin-read-write.md index fad76a59..dc94ca7a 100644 --- a/tests/testthat/_snaps/pin-read-write.md +++ b/tests/testthat/_snaps/pin-read-write.md @@ -19,6 +19,11 @@ Condition Error in `pin_write()`: ! `name` must be a string + Code + pin_write(board, mtcars, name = "mtcars", "json") + Condition + Error in `pin_write()`: + ! Arguments after the dots `...` must be named, like `type = "json"`. Code pin_write(board, mtcars, name = "mtcars", type = "froopy-loops") Condition diff --git a/tests/testthat/test-pin-read-write.R b/tests/testthat/test-pin-read-write.R index 593532d5..0ba84050 100644 --- a/tests/testthat/test-pin-read-write.R +++ b/tests/testthat/test-pin-read-write.R @@ -41,6 +41,7 @@ test_that("useful errors on bad inputs", { expect_snapshot(error = TRUE, { pin_write(mtcars) pin_write(board, mtcars, name = 1:10) + pin_write(board, mtcars, name = "mtcars", "json") pin_write(board, mtcars, name = "mtcars", type = "froopy-loops") pin_write(board, mtcars, name = "mtcars", metadata = 1) }) @@ -65,7 +66,7 @@ test_that("pin_write() noisily generates name and type", { test_that("user can supply metadata", { board <- board_temp() - pin_write(board, 1:10, "x", metadata = list(name = "Susan"), desc = "A vector") + pin_write(board, 1:10, "x", metadata = list(name = "Susan"), description = "A vector") meta <- pin_meta(board, "x") expect_equal(meta$user, list(name = "Susan")) expect_equal(meta$description, "A vector")