Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create function for newdata alert #525

Closed
EmilHvitfeldt opened this issue Jul 3, 2021 · 1 comment · Fixed by #912
Closed

Create function for newdata alert #525

EmilHvitfeldt opened this issue Jul 3, 2021 · 1 comment · Fixed by #912
Labels
feature a feature request or enhancement

Comments

@EmilHvitfeldt
Copy link
Member

Should the following code be wrapped up in an exported helper function?

parsnip/R/linear_reg.R

Lines 236 to 237 in 37b07cb

if (any(names(enquos(...)) == "newdata"))
rlang::abort("Did you mean to use `new_data` instead of `newdata`?")

It is used a couple of handfuls of times in this package along with other add-on packages.

newdata_abort <- function(...) {
  if (any(names(rlang::enquos(...)) == "newdata")) 
   rlang::abort("Did you mean to use `new_data` instead of `newdata`?") 
}

test <- function(...) {
  newdata_abort(...)
  list(...)
}

test(new_data = "hello")
#> $new_data
#> [1] "hello"


test(newdata = "hello")
#> Error: Did you mean to use `new_data` instead of `newdata`?

Created on 2021-07-03 by the reprex package (v2.0.0)

@juliasilge juliasilge added the feature a feature request or enhancement label Jul 3, 2021
@github-actions
Copy link

This issue 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.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature a feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants