def _check_colors(self):
        """
        dmenu needs colours to be in #rgb or #rrggbb format.

        Checks colour value, removes invalid values and adds # if missing.

        NB This should not be called in _Extension.__init__ as _Extension.global_defaults
        may not have been set at this point.
        """
        for c in ["background", "foreground", "selected_background", "selected_foreground"]:
            col = getattr(self, c, None)
            if col is None:
                continue

            if not isinstance(col, str) or not RGB.match(col):
                logger.warning(
                    "Invalid extension '%s' color: %s. Must be #RGB or #RRGGBB string.", c, col
                )
                setattr(self, c, None)
                continue

            if not col.startswith("#"):
                col = f"#{col}"
                setattr(self, c, col)

        dmenu needs colours to be in #rgb or #rrggbb format.

        Checks colour value, removes invalid values and adds # if missing.

        NB This should not be called in _Extension.__init__ as _Extension.global_defaults
        may not have been set at this point.
        
libqtile/extension/base.py