Mixing imports and "computations"

I have this set of code at the beginning of my notebook:

try:
    from osgeo import gdal
except ImportError:
    GDAL_INSTALLED = False
    logger.warning(
        "No GDAL found. Some planetary.utils functions not working, but okay."
    )
else:
    GDAL_INSTALLED = True

and am getting nbdev processor warnings about it due to mixing of imports and “computations”.

What is the recommended way to achieve what I’m doing (to get a logging warning for a failed import) without producing warnings at nbdev?

If you create a new cell with

if not GDAL_INSTALLED: warn(...)

does that work?