gesistsa / rio

🐟 A Swiss-Army Knife for Data I/O
http://gesistsa.github.io/rio/
594 stars 77 forks source link

add tweaks for #409 #411

Closed chainsawriot closed 2 months ago

chainsawriot commented 2 months ago
chainsawriot commented 2 months ago

@jsonbecker I think the deprecation message is better with this PR.

options(lifecycle_verbosity = "warning") ## always

rio::import(rio::export(head(iris), tempfile(fileext = ".rds")))
#> Warning: The `trust` argument of `import()` should be explicit for serialization formats
#> as of rio 1.0.3.
#> ℹ Missing `trust` will be set to FALSE by default for RDS in 2.0.0.
#> ℹ The deprecated feature was likely used in the rio package.
#>   Please report the issue at <https://github.com/gesistsa/rio/issues>.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1          5.1         3.5          1.4         0.2  setosa
#> 2          4.9         3.0          1.4         0.2  setosa
#> 3          4.7         3.2          1.3         0.2  setosa
#> 4          4.6         3.1          1.5         0.2  setosa
#> 5          5.0         3.6          1.4         0.2  setosa
#> 6          5.4         3.9          1.7         0.4  setosa

rio::import(rio::export(head(iris), tempfile(fileext = ".rds")), trust = TRUE)
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1          5.1         3.5          1.4         0.2  setosa
#> 2          4.9         3.0          1.4         0.2  setosa
#> 3          4.7         3.2          1.3         0.2  setosa
#> 4          4.6         3.1          1.5         0.2  setosa
#> 5          5.0         3.6          1.4         0.2  setosa
#> 6          5.4         3.9          1.7         0.4  setosa

rio::import(rio::export(head(iris), tempfile(fileext = ".rds")), trust = FALSE)
#> Error: RDS files may execute arbitary code. Only load RDS files that you personally generated or can trust the origin.

Created on 2024-05-13 with reprex v2.1.0

chainsawriot commented 2 months ago

For comparison, HEAD

options(lifecycle_verbosity = "warning") ## always

rio::import(rio::export(head(iris), tempfile(fileext = ".rds")))
#> Warning: The `trust` argument of `import()` is deprecated as of rio 2.0.0.
#> ℹ Trust will be set to FALSE by default for Rds.
#> ℹ The deprecated feature was likely used in the rio package.
#>   Please report the issue at <https://github.com/gesistsa/rio/issues>.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1          5.1         3.5          1.4         0.2  setosa
#> 2          4.9         3.0          1.4         0.2  setosa
#> 3          4.7         3.2          1.3         0.2  setosa
#> 4          4.6         3.1          1.5         0.2  setosa
#> 5          5.0         3.6          1.4         0.2  setosa
#> 6          5.4         3.9          1.7         0.4  setosa

rio::import(rio::export(head(iris), tempfile(fileext = ".rds")), trust = TRUE)
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1          5.1         3.5          1.4         0.2  setosa
#> 2          4.9         3.0          1.4         0.2  setosa
#> 3          4.7         3.2          1.3         0.2  setosa
#> 4          4.6         3.1          1.5         0.2  setosa
#> 5          5.0         3.6          1.4         0.2  setosa
#> 6          5.4         3.9          1.7         0.4  setosa

rio::import(rio::export(head(iris), tempfile(fileext = ".rds")), trust = FALSE)
#> Error: Rdsfiles may execute arbitary code. Only loadRdsfiles that you personally generated or can trust the origin.

Created on 2024-05-13 with reprex v2.1.0

jsonbecker commented 2 months ago

Oh I like the use of getOptions.