STYLE: Fix lint error "F811 redefinition of unused 'setup'" in benchmarks #22885
Labels
CI
Continuous Integration
Code Style
Code style, linting, code_checks
good first issue
Needs Discussion
Requires discussion from core team before further action
Milestone
(related to #22884)
There is an issue in the linting of the benchmarks, caused by how
asv
manages reusing asetup
function. See:The problem is that to make
asv
reuse a commonsetup
function for all the benchmarks in a file, it is expected to have it defined in the top-level namespace. Then every benchmark class in the file can specify asetup
method that will be executed after the common one. See this sample code:Regardless if this is a good approach by
asv
, the problem is that the previous code causes linting problems (the error shown before). In this case, thesetup
defined inpandas_vb_common.py
simply defines the seed,np.random.seed(1234)
.It's not a great option, but we could move the import of
setup
at the end of the file (so, the methods are not seen as redefinitions), and flag it to ignore the validation of not being used:from .pandas_vb_common import setup # noqa: F401
. But I find this one trickier, as it's difficult to see that there is a common setup being executed, unless you go at the end of the file.Those are the affected files:
The text was updated successfully, but these errors were encountered: