klmr / box

Write reusable, composable and modular R code
https://klmr.me/box/
MIT License
862 stars 48 forks source link

Add explicit binding #355

Open stefanoborini opened 7 months ago

stefanoborini commented 7 months ago

I thought I already filed this, but I cannot find it. Sorry if it's a reiterated request.

The problem we have with box is that the imported symbols are not explicitly bound. This angers linters, that see a symbol appear out of thin air and start complaining.

Example

box::use(mod/hello_world)

hello_world$hello('Ross')

This would trigger a linter problem because hello_world appears from nowhere.

I propose to support the additional syntax

hello_world <- box::use("mod/hello_world")

hello_world$hello('Ross')

This has the added benefit of allowing for easy renaming of the module in case of collision.

caldwellst commented 4 months ago

Second this, as I have to disable the OBJECT_USAGE_LINTER from {lintr} in codebases using {box} for this reason. However, wondering if support for box::use() syntax could be incorporated into {lintr} to maintain the current syntax, as I think that matches syntax extremely common in Python and many other languages.

caldwellst commented 4 months ago

https://github.com/r-lib/lintr/issues/2060

radbasa commented 3 months ago

@caldwellst Please take a look at {box.linters}. We would appreciate feedback.

caldwellst commented 3 months ago

Ah thanks so much, will 100% do so!