Here's what I get when I run pylint 2.4 locally.
************* Module adafruit_imageload.bmp
adafruit_imageload/bmp/__init__.py:68:4: C0415: Import outside toplevel (%s) (import-outside-toplevel)
************* Module adafruit_imageload
adafruit_imageload/__init__.py:49:12: C0415: Import outside toplevel (%s) (import-outside-toplevel)
adafruit_imageload/__init__.py:53:12: C0415: Import outside toplevel (%s) (import-outside-toplevel)
adafruit_imageload/__init__.py:57:12: C0415: Import outside toplevel (%s) (import-outside-toplevel)
************* Module adafruit_imageload.pnm
adafruit_imageload/pnm/__init__.py:53:16: C0415: Import outside toplevel (%s) (import-outside-toplevel)
adafruit_imageload/pnm/__init__.py:60:16: C0415: Import outside toplevel (%s) (import-outside-toplevel)
adafruit_imageload/pnm/__init__.py:67:16: C0415: Import outside toplevel (%s) (import-outside-toplevel)
adafruit_imageload/pnm/__init__.py:79:16: C0415: Import outside toplevel (%s) (import-outside-toplevel)
adafruit_imageload/pnm/__init__.py:85:12: C0415: Import outside toplevel (%s) (import-outside-toplevel)
************* Module adafruit_imageload.pnm.pgm
adafruit_imageload/pnm/pgm/__init__.py:43:8: C0415: Import outside toplevel (%s) (import-outside-toplevel)
adafruit_imageload/pnm/pgm/__init__.py:48:8: C0415: Import outside toplevel (%s) (import-outside-toplevel)
bmp/__init__.py
The lines in question:
from . import indexed
return indexed.load(
file,
width,
height,
data_start,
colors,
color_depth,
compression,
bitmap=bitmap,
palette=palette,
)
__init__.py
The lines in question:
if header.startswith(b"BM"):
from . import bmp
return bmp.load(file, bitmap=bitmap, palette=palette)
if header.startswith(b"P"):
from . import pnm
return pnm.load(file, header, bitmap=bitmap, palette=palette)
if header.startswith(b"GIF"):
from . import gif
pnm/__init__.py
The lines in question:
if magic_number in [b"P2", b"P5"]:
from . import pgm
return pgm.load(
file, magic_number, pnm_header, bitmap=bitmap, palette=palette
)
if magic_number == b"P3":
from . import ppm_ascii
return ppm_ascii.load(
file, pnm_header[0], pnm_header[1], bitmap=bitmap, palette=palette
)
if magic_number == b"P6":
from . import ppm_binary
return ppm_binary.load(
file, pnm_header[0], pnm_header[1], bitmap=bitmap, palette=palette
)
and
if magic_number.startswith(b"P1"):
from . import pbm_ascii
return pbm_ascii.load(
file, pnm_header[0], pnm_header[1], bitmap=bitmap, palette=palette
)
from . import pbm_binary
return pbm_binary.load(
file, pnm_header[0], pnm_header[1], bitmap=bitmap, palette=palette
)
pnm/pgm/__init__.py
And finally:
if magic_number == b"P2": # To handle ascii PGM files.
from . import ascii as pgm_ascii
return pgm_ascii.load(file, width, height, bitmap=bitmap, palette=palette)
if magic_number == b"P5": # To handle binary PGM files.
from . import binary
return binary.load(file, width, height, bitmap=bitmap, palette=palette)
I'm not sure how resource-intensive the imported libraries are, but I'd assume for something that loads images, they might take up quite a bit of memory. It'd be useful to have someone test this on a board with a smallish amount of memory to see if it still works when everything is imported at once at the top of the file.
Referencing main issue: adafruit/Adafruit_CircuitPython_Bundle#232