Skip to content

Thoughts on turning adafruit_bitmap_font / adafruit_fakerequests into a soft dependency? #55

@joshkehn

Description

@joshkehn

It looks like adafruit_bitmap_font (repo) is used as a convenience function to _load_font:

if font not in self._fonts:
self._fonts[font] = bitmap_font.load_font(font)

This could be turned into an inline import. For example:

 if font not in self._fonts:
    from adafruit_bitmap_font import bitmap_font  # <-- Inline import 
    self._fonts[font] = bitmap_font.load_font(font)

Turning this into an inline import would make this a soft dependency. If it's not used it's not required. I was working up a small demo on the MagTag but not using anything about the display or Wi-Fi. I noticed that I still needed quite a few libraries. Some of these, like adafruit_fakerequests, aren't used even if I was using the full capabilities on the device. For example, this line could also use an inline import:

response = Fake_Requests(LOCALFILE)

Making these inline imports would reduce the number of hard dependencies here. This would also provide some space savings and improve the speed at which the code starts up. This also shouldn't functionally impact any existing example code which makes use of functions requiring these libraries. They would still require the library to be installed.

Is this worth submitting a PR for?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions