rstudio / pins-r

Pin, Discover and Share Resources
https://pins.rstudio.com
Other
301 stars 62 forks source link

Change the `pin_write()` function signature, moving the dots #792

Closed juliasilge closed 9 months ago

juliasilge commented 9 months ago

We've been talking about ... being in the wrong place for quite a while, and we think it's time to rip the band-aid off for a better experience for people.

Technically we "should" put the dots before name but it is very very very common for folks to provide name by position (without name =). We do it in all our docs and tests, and I believe it is very common with users as well. I would like to propose that we move the dots to between name and type, as it will not be too disruptive for users and we'll be able to get to our better situation of moving around or adding args after the dots.

The new error that folks see if they are passing by position is this:

library(pins)
board <- board_temp()
board |> pin_write(10:20, "nice-numbers", "json", "my great title")
#> Error in `pin_write()`:
#> ! Arguments after the dots `...` must be named, like `type = "json"`.
#> Backtrace:
#>     ▆
#>  1. └─pins::pin_write(board, 10:20, "nice-numbers", "json", "my great title")
#>  2.   └─cli::cli_abort("Arguments after the dots `...` must be named, like {.code type = \"{dots[[1]]}\"}.") at pins-r/R/pin-read-write.R:85:4
#>  3.     └─rlang::abort(...)

Created on 2023-09-29 with reprex v2.0.2

The message doesn't make quite as much sense if people are using a mix of calling by name and position, but surely this must be rare:

library(pins)
board <- board_temp()
board |> pin_write(10:20, name = "nice-numbers", type = "json", "my great title")
#> Error in `pin_write()`:
#> ! Arguments after the dots `...` must be named, like `type = "my great
#>   title"`.
#> Backtrace:
#>     ▆
#>  1. └─pins::pin_write(board, 10:20, name = "nice-numbers", type = "json", "my great title")
#>  2.   └─cli::cli_abort("Arguments after the dots `...` must be named, like {.code type = \"{dots[[1]]}\"}.") at pins-r/R/pin-read-write.R:85:4
#>  3.     └─rlang::abort(...)

Created on 2023-09-29 with reprex v2.0.2

At least they are still getting an error with some helpful info, even if it isn't as fully helpful.

github-actions[bot] commented 8 months ago

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.