Skip to content

Verbosity is not respected on R6 init calls #208

@averissimo

Description

@averissimo

Problem:

When initializing an R6 class that contains a deprecate_warn it only throws the message the first time. Both when running with lifecycle_verbosity R option and in the {testthat} expectation.

Expected behavior

It should throw the warning on every call if verbosity is set to warning

Reproducible code below:

rlang::local_options(lifecycle_verbosity = "warning")
A <- R6::R6Class("A", list(
  initialize = function() {
    lifecycle::deprecate_warn('1.0.0', 'A$new()')
  }
))
A$new()
#> Warning message:
#> `A$new()` was deprecated in <NA> 1.0.0.
#> ℹ The deprecated feature was likely used in the R6 package.
#>   Please report the issue at <[https://github.com/r-lib/R6/issues](vscode-file://vscode-app/usr/share/positron/resources/app/out/vs/code/electron-browser/workbench/workbench.html#)>.
#> This warning is displayed once per session.
#> Call [lifecycle::last_lifecycle_warnings()](vscode-file://vscode-app/usr/share/positron/resources/app/out/vs/code/electron-#> browser/workbench/workbench.html#) to see where this warning was generated. 
#> <A>
#>   Public:
#>     clone: function (deep = FALSE) 
#>     initialize: function ()
A$new()
#> <A>
#>   Public:
#>     clone: function (deep = FALSE) 
#>     initialize: function () 
lifecycle::expect_deprecated(A$new())
#> Error:
#> ! Expected `A$new()` to produce warnings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions