Repository: matplotlib/matplotlib
File: lib/matplotlib/legend.py (Python)

Code before:
                    pass
                for getter_name in getter_names:
                    try:
                        color = getattr(handle, getter_name)()
                        if isinstance(color, np.ndarray):
                            if color.size == 0:
                                continue
                            elif (
                                color.shape[0] == 1
                                or np.isclose(color, color[0]).all()
                            ):
                                text.set_color(color[0])
                            else:
                                pass
                        elif isinstance(color, str) and str(color).lower() == 'none':
                            continue
                        elif (len(mpl.colors.to_rgba(color)) == 4
                              and mpl.colors.to_rgba(color)[3] == 0):
                                continue
                        else:
                            text.set_color(color)
                        break
                    except AttributeError:
                        continue
                else:
                    text.set_color('none')
        elif cbook._str_equal(labelcolor, 'none'):
            for text in self.texts:
                text.set_color(labelcolor)
        elif np.iterable(labelcolor):
            for text, color in zip(self.texts,
                                   itertools.cycle(
                                       colors.to_rgba_array(labelcolor))):
                text.set_color(color)
        else:
            raise ValueError(f"Invalid labelcolor: {labelcolor!r}")

    def _set_artist_props(self, a):
        """
        Set the boilerplate props for artists added to Axes.
        """
        a.set_figure(self.get_figure(root=False))
        if self.isaxes:
            a.axes = self.axes

        a.set_transform(self.get_transform())

    @_docstring.interpd
    def set_loc(self, loc=None):
        """
        Set the location of the legend.

Review comment (bug):
If I understand correctly this is executed as a fallback if color could not be detected. Then, it feels wrong to set full transparency, because it makes the text invisible. I think we should rather leave the default as we did before.

Code after:
                    pass
                for getter_name in getter_names:
                    try:
                        color = getattr(handle, getter_name)()
                    except AttributeError:
                        continue
                    if isinstance(color, np.ndarray):
                        if color.size == 0:
                            continue
                        elif (color.shape[0] == 1 or np.isclose(color, color[0]).all()):
                            text.set_color(color[0])
                        else:
                            pass
                    elif cbook._str_lower_equal(color, 'none'):
                        continue
                    elif mpl.colors.to_rgba(color)[3] == 0:
                        continue
                    else:
                        text.set_color(color)
                    break
        elif cbook._str_equal(labelcolor, 'none'):
            for text in self.texts:
                text.set_color(labelcolor)
        elif np.iterable(labelcolor):
            for text, color in zip(self.texts,
                                   itertools.cycle(
                                       colors.to_rgba_array(labelcolor))):
                text.set_color(color)
        else:
            raise ValueError(f"Invalid labelcolor: {labelcolor!r}")

    def _set_artist_props(self, a):
        """
        Set the boilerplate props for artists added to Axes.
        """
        a.set_figure(self.get_figure(root=False))
        if self.isaxes:
            a.axes = self.axes

        a.set_transform(self.get_transform())

    @_docstring.interpd
    def set_loc(self, loc=None):
        """
        Set the location of the legend.

        .. versionadded:: 3.8

        Parameters
        ----------
        %(_legend_kw_set_loc_doc)s