rticulate / import

An Import Mechanism For R
https://import.rticulate.org
Other
222 stars 14 forks source link

Using library() inside imported module should be an error #44

Closed torfason closed 3 years ago

torfason commented 3 years ago

If a module loads a package through a library() statement, this allows functions to be defined relying on the package, but then they won't work outside the module, with an error that can be cryptic to users.

This behavior is as documented in the readme (https://import.rticulate.org/), but it seems better to throw an error immediately on the import::from() call if this occurs.

Implementing this seems trivial by checking whether .packages() changes during the sourcing of the module. I expect to prepare a PR shortly that does this. Comments/pros/cons/OK appreciated.

torfason commented 3 years ago

On closer thought, perhaps a warning is enough here ...