Crunch-io / rcrunch

R package for interacting with the Crunch API
https://crunch.io/r/crunch/
GNU Lesser General Public License v3.0
9 stars 15 forks source link

[179197673]: avoid warning R 4.1 #578

Closed gergness closed 3 years ago

gergness commented 3 years ago

A lazy way to avoid the warning introduced in R 4.1.

[crunch] > names(categories(ds$try_change41)) <- c("a", "b", "c")
Warning message:
In class(x) <- unique.default(c("AsIs", oldClass(x))) :
  Setting class(x) to multiple strings ("AsIs", "Categories", ...); result will no longer be an S4 object

This I() is called when trying to check if the new categories are the same as the existing ones so that it can avoid a no-op PATCH. However, while tracking this warning message, I noticed that updating categories like this does not actually work, because slot(x, "body")[[i]] where x is a VariableEntity and i is "categories" is a regular R list (has not yet been converted to a Categories S4 object), but value is a true Categories S4 object.

I did a little bit of work trying to make this better, but it doesn't feel worth it to pursue further. I'll link to this with an issue to capture the work I did.

codecov[bot] commented 3 years ago

Codecov Report

Merging #578 (e2c52e7) into master (bfc44f5) will increase coverage by 0.00%. The diff coverage is 100.00%.

:exclamation: Current head e2c52e7 differs from pull request most recent head 486505a. Consider uploading reports for the commit 486505a to get more accurate results Impacted file tree graph

@@           Coverage Diff           @@
##           master     #578   +/-   ##
=======================================
  Coverage   90.62%   90.62%           
=======================================
  Files         128      128           
  Lines        8179     8183    +4     
=======================================
+ Hits         7412     7416    +4     
  Misses        767      767           
Impacted Files Coverage Δ
R/cube-result.R 97.73% <ø> (ø)
R/api.R 93.18% <100.00%> (+0.15%) :arrow_up:
R/misc.R 98.93% <100.00%> (+0.01%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update bfc44f5...486505a. Read the comment docs.