Skip to content

Conversation

hadley
Copy link
Member

@hadley hadley commented Aug 23, 2024

No description provided.

@hadley hadley changed the title Deprecate old mocking functions Deprecate and remove old mocking functions Nov 15, 2024
@hadley
Copy link
Member Author

hadley commented Jan 10, 2025

Code used to inform users:

```R library(gh) library(purrr) library(dplyr)

packages <-tribble(
~package, ~github_url,
"countdown", "https://github.com/gadenbuie/countdown",
"covr", "https://github.com/r-lib/covr",
"crossmap", "https://github.com/rossellhayes/crossmap",
"crplyr", "https://github.com/Crunch-io/crplyr",
"crunch", "https://github.com/Crunch-io/rcrunch",
"crunchy", "https://github.com/Crunch-io/crunchy",
"cyphr", "https://github.com/ropensci/cyphr",
"datarobot", NA,
"dendextend", "https://github.com/talgalili/dendextend",
"digitize", "https://github.com/tpoisot/digitize",
"distro", NA,
"dRiftDM", "https://github.com/bucky2177/dRiftDM",
"DSMolgenisArmadillo", "https://github.com/molgenis/molgenis-r-datashield",
"gbfs", "https://github.com/simonpcouch/gbfs",
"gen3sis", "https://github.com/project-Gen3sis/R-package",
"graphhopper", "https://github.com/crazycapivara/graphhopper-r",
"gwasrapidd", "https://github.com/ramiromagno/gwasrapidd",
"hereR", "https://github.com/munterfi/hereR",
"humanize", "https://github.com/newtux/humanize",
"ieegio", "https://github.com/dipterix/ieegio",
"ipaddress", "https://github.com/davidchall/ipaddress",
"isotracer", NA,
"JAGStree", "https://github.com/malfly/JAGStree",
"leaflet.minicharts", NA,
"learnr", "https://github.com/rstudio/learnr",
"MakefileR", "https://github.com/krlmlr/MakefileR",
"manipulateWidget", "https://github.com/rte-antares-rpackage/manipulateWidget",
"mbbe", "https://github.com/certara/mbbe",
"metaDigitise", "https://github.com/daniel1noble/metaDigitise",
"mknapsack", "https://github.com/madedotcom/mknapsack",
"mockery", "https://github.com/r-lib/mockery",
"moexer", "https://github.com/x1o/moexer",
"MolgenisArmadillo", "https://github.com/molgenis/molgenis-r-armadillo",
"MolgenisAuth", "https://github.com/molgenis/molgenis-r-auth",
"NasdaqDataLink", "https://github.com/nasdaq/data-link-r",
"nhlapi", "https://github.com/jozefhajnala/nhlapi",
"odin", "https://github.com/mrc-ide/odin",
"opendatatoronto", "https://github.com/sharlagelfand/opendatatoronto",
"overture", "https://github.com/kurtis-s/overture",
"owmr", "https://github.com/crazycapivara/owmr",
"oxcAAR", NA,
"passport", "https://github.com/alistaire47/passport",
"patrick", "https://github.com/google/patrick",
"plumber", "https://github.com/rstudio/plumber",
"pocketapi", "https://github.com/CorrelAid/pocketapi",
"projmgr", "https://github.com/emilyriederer/projmgr",
"Quandl", "https://github.com/quandl/quandl-r",
"regmedint", "https://github.com/kaz-yos/regmedint",
"rentrez", "https://github.com/ropensci/rentrez",
"reportr", "https://github.com/jonclayden/reportr",
"restez", "https://github.com/ropensci/restez",
"Rexperigen", "https://github.com/aquincum/Rexperigen",
"rnbp", "https://github.com/szymanskir/rnbp",
"rosetteApi", NA,
"Rpolyhedra", "https://github.com/ropensci/Rpolyhedra",
"RPresto", "https://github.com/prestodb/RPresto",
"RTD", "https://github.com/treasure-data/RTD",
"Ryacas0", "https://github.com/r-cas/ryacas0",
"shiny.benchmark", "https://github.com/Appsilon/shiny.benchmark",
"shinyShortcut", NA,
"skimr", "https://github.com/ropensci/skimr",
"spaero", "https://github.com/e3bo/spaero",
"starwarsdb", "https://github.com/gadenbuie/starwarsdb",
"taxonomizr", "https://github.com/sherrillmix/taxonomizr",
"texreg", "https://github.com/leifeld/texreg",
"ThankYouStars", "https://github.com/ksmzn/ThankYouStars",
"tinyProject", NA,
"tryCatchLog", "https://github.com/aryoda/tryCatchLog",
"tuneRanger", NA,
"uptasticsearch", "https://github.com/uptake/uptasticsearch",
"WhatIf", "https://github.com/IQSS/WhatIf",
"ZillowR", NA,
"zoltr", "https://github.com/reichlab/zoltr"
)

Function to extract owner/repo from GitHub URL

extract_repo_info <- function(url) {
parts <- strsplit(gsub("https://github.com/", "", url), "/")[[1]]
list(owner = parts[1], repo = parts[2])
}

packages_df <- packages %>%
filter(!is.na(github_url)) %>%
mutate(
repo_info = map(github_url, extract_repo_info),
owner = map_chr(repo_info, "owner"),
repo = map_chr(repo_info, "repo")
) %>%
select(-repo_info) # Clean up the intermediate list-column

Function to create an issue

create_issue <- function(owner, repo) {

tryCatch({
gh::gh(
"POST /repos/{owner}/{repo}/issues",
owner = owner,
repo = repo,
title = "with_mock() is going away",
body = "This is a heads up to let you know that with_mock() is deprecated and will be made defunct soon. The API functions that made it work are being removed in R 4.5.0, so we'd suggest that you switch to with_mocked_bindings() instead."
)
message(sprintf("Successfully created issue for %s/%s", owner, repo))
}, error = function(e) {
message(sprintf("Failed to create issue for %s/%s: %s", owner, repo, e$message))
})

Sleep to avoid hitting rate limits

Sys.sleep(.1)
}

walk2(packages_df$owner, packages_df$repo, create_issue)

</details>

@hadley
Copy link
Member Author

hadley commented Aug 9, 2025

Issues files and emails sent again today.

```R library(gh) library(purrr) library(dplyr)

packages <- tribble(
~package, ~github_url,
"aws.comprehend", "https://github.com/cloudyr/aws.comprehend",
"bcRP", "https://github.com/JulioCollazos64/bcRP",
"bindr", "https://github.com/krlmlr/bindr",
"conflr", "https://github.com/line/conflr",
"countdown", "https://github.com/gadenbuie/countdown",
"covr", "https://github.com/r-lib/covr",
"datarobot", "NA",
"digitize", "https://github.com/tpoisot/digitize",
"distro", "NA",
"esci", "https://github.com/rcalinjageman/esci",
"gen3sis", "https://github.com/project-Gen3sis/R-package",
"geomorph", "https://github.com/geomorphR/geomorph",
"graphhopper", "https://github.com/crazycapivara/graphhopper-r",
"handwriterRF", "https://github.com/CSAFE-ISU/handwriterRF",
"humanize", "https://github.com/newtux/humanize",
"ipaddress", "https://github.com/davidchall/ipaddress",
"leaflet.minicharts", "NA",
"learnr", "https://github.com/rstudio/learnr",
"MakefileR", "https://github.com/krlmlr/MakefileR",
"manipulateWidget", "https://github.com/rte-antares-rpackage/manipulateWidget",
"mbbe", "https://github.com/certara/mbbe",
"metaDigitise", "https://github.com/daniel1noble/metaDigitise",
"mknapsack", "https://github.com/madedotcom/mknapsack",
"mockery", "https://github.com/r-lib/mockery",
"moexer", "https://github.com/x1o/moexer",
"MolgenisArmadillo", "https://github.com/molgenis/molgenis-r-armadillo",
"NasdaqDataLink", "https://github.com/nasdaq/data-link-r",
"nhlapi", "https://github.com/jozefhajnala/nhlapi",
"owmr", "https://github.com/crazycapivara/owmr",
"oxcAAR", "NA",
"parameters", "https://github.com/easystats/parameters",
"passport", "https://github.com/alistaire47/passport",
"pocketapi", "https://github.com/CorrelAid/pocketapi",
"projmgr", "https://github.com/emilyriederer/projmgr",
"PubChemR", "https://github.com/selcukorkmaz/PubChemR",
"Quandl", "https://github.com/quandl/quandl-r",
"REddyProc", "https://github.com/bgctw/REddyProc",
"regmedint", "https://github.com/kaz-yos/regmedint",
"Rexperigen", "https://github.com/aquincum/Rexperigen",
"rosetteApi", "NA",
"Rpolyhedra", "https://github.com/ropensci/Rpolyhedra",
"RPresto", "https://github.com/prestodb/RPresto",
"RTD", "https://github.com/treasure-data/RTD",
"Ryacas0", "https://github.com/r-cas/ryacas0",
"shiny.benchmark", "https://github.com/Appsilon/shiny.benchmark",
"shinyShortcut", "NA",
"skimr", "https://github.com/ropensci/skimr",
"spaero", "https://github.com/e3bo/spaero",
"starwarsdb", "https://github.com/gadenbuie/starwarsdb",
"tangles", "NA",
"texreg", "https://github.com/leifeld/texreg",
"ThankYouStars", "https://github.com/ksmzn/ThankYouStars",
"tinyProject", "NA",
"tryCatchLog", "https://github.com/aryoda/tryCatchLog",
"WhatIf", "https://github.com/IQSS/WhatIf",
"ZillowR", "NA"
)

Function to extract owner/repo from GitHub URL

extract_repo_info <- function(url) {
parts <- strsplit(gsub("https://github.com/", "", url), "/")[[1]]
list(owner = parts[1], repo = parts[2])
}

packages_df <- packages %>%
filter(!is.na(github_url)) %>%
mutate(
repo_info = map(github_url, extract_repo_info),
owner = map_chr(repo_info, "owner"),
repo = map_chr(repo_info, "repo")
) %>%
select(-repo_info) # Clean up the intermediate list-column

Function to create an issue

create_issue <- function(owner, repo) {

tryCatch({
gh::gh(
"POST /repos/{owner}/{repo}/issues",
owner = owner,
repo = repo,
title = "with_mock() is going away (2)",
body = "This is a second reminder that with_mock() is going away in the next release of testthat, which I'm aiming to release October 1. The API functions that made it work are being removed in R 4.5.0, so we'd suggest that you switch to with_mocked_bindings()/local_mocked_bindings() instead."
)
message(sprintf("Successfully created issue for %s/%s", owner, repo))
}, error = function(e) {
message(sprintf("Failed to create issue for %s/%s: %s", owner, repo, e$message))
})

Sleep to avoid hitting rate limits

Sys.sleep(.1)
}

walk2(packages_df$owner, packages_df$repo, create_issue)

to_email <- packages_df |> filter(is.na(repo)) |> pull(package)
cran_packages <- devtools:::cran_packages()
emails <- cran_packages[to_email, "Maintainer"]
base::writeLines(emails)

body <- paste0(gsub(" <.*?>", "", emails), ": ", names(emails))
base::writeLines(body)

</details>

@hadley hadley merged commit 7eb22e8 into main Aug 9, 2025
13 checks passed
@hadley hadley deleted the deprecate-mock branch August 9, 2025 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant