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

Unable to deprecate an R6 class #149

Open
CollinErickson opened this issue Dec 2, 2022 · 1 comment
Open

Unable to deprecate an R6 class #149

CollinErickson opened this issue Dec 2, 2022 · 1 comment
Labels
feature a feature request or enhancement

Comments

@CollinErickson
Copy link

I am unable to deprecate an entire R6 class. There was an issue for deprecating an R6 method (#54) that was fixed, but that does not seem to work within initialize. If I'm missing something, please let me know.

Minimal reprex:

A <- R6::R6Class("A", list(
  initialize = function() {
    lifecycle::deprecate_soft('1.0.0', 'A$new()')
  }
))
A$new()
# No deprecation warning
@hadley
Copy link
Member

hadley commented Nov 2, 2023

A non-soft deprecation works:

A <- R6::R6Class("A", list(
  initialize = function() {
    lifecycle::deprecate_warn('1.0.0', 'A$new()')
  }
))
A$new()
#> Warning: `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>.
#> <A>
#>   Public:
#>     clone: function (deep = FALSE) 
#>     initialize: function ()

Created on 2023-11-02 with reprex v2.0.2

I think the problem here is that initialize() is not called directly by the user, so the soft deprecation path doesn't trigger. Not sure if there's anything we can do about this

@hadley hadley added the feature a feature request or enhancement label Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants